Using GitHub Copilot for Free in VS Code for Test Automation

Share with friends
Save Story for Later (1)
Please login to bookmark Close

The AI Revolution in Test Automation

If you’re an SDET, you know that writing test scripts, maintaining automation frameworks, and debugging flaky tests take up a significant portion of your time. What if I told you that GitHub Copilot Free can handle a chunk of that work for you – at zero cost?

With GitHub Copilot Free, you get:


2,000 code completions per month (perfect for test automation snippets)
50 chat requests per month (great for asking AI about test strategies, regex patterns, and framework improvements)
Access to GPT-4o and Claude 3.5 Sonnet (intelligent assistance in writing and refactoring automation scripts)

No trial, no subscription, no credit card required. Just install VS Code, log in with your GitHub account, and you’re ready to go.


🔥 Why Should SDETs Care?

Test automation engineers deal with repetitive coding tasks, debugging, and optimizing test scripts. GitHub Copilot reduces manual effort, letting you focus on test strategy, reliability, and scalability.

How to Set up Visual Studio Code with Copilot?

  • Download and install Visual Studio Code for your platform
  • Start VS Code
  • Select Use AI Features with Copilot for Free… from the Copilot menu in the title bar or from the Command Palette
  • Select Sign in to Use Copilot for Free to sign in to your GitHub account and sign up for Copilot Free
  • If you already have a Copilot subscription associated with your GitHub account, VS Code uses that one after you sign in.
  • Get started by entering a prompt in the chat input field

Gain insights into GitHub Copilot and see it in action, expertly presented by Gaurav Khurana.


Let’s look at real-world SDET use cases where GitHub Copilot can supercharge your workflow:

🛠 1. Generating Selenium & Playwright Test Scripts

Before Copilot: You manually write boilerplate code for Selenium test scripts, including imports, setup, and teardown methods.

With Copilot: Just type a function name like test_login_page and Copilot suggests the entire test script.

Example: Generating a Selenium Test in Python

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys

def test_login_page():
    driver = webdriver.Chrome()
    driver.get("https://example.com/login")
    driver.find_element(By.ID, "username").send_keys("testuser")
    driver.find_element(By.ID, "password").send_keys("securepassword")
    driver.find_element(By.ID, "login-button").click()
    assert "Dashboard" in driver.title
    driver.quit()

💡 Bonus Tip: Use Copilot Edits to auto-refactor tests when element locators change!


⚡ 2. Writing API Test Automation with RestAssured (Java)

Manually crafting API test cases can be tedious, especially when handling headers, authentication, and response validation.

Before Copilot: You write API test cases from scratch.

With Copilot: Just type testGetUserDetails() and Copilot autocompletes an entire test method.

Example: Writing an API Test in Java with RestAssured

mport io.restassured.RestAssured;
import io.restassured.response.Response;
import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;

public class APITests {
    @Test
    public void testGetUserDetails() {
        given()
            .header("Authorization", "Bearer your_token")
        .when()
            .get("https://api.example.com/users/123")
        .then()
            .statusCode(200)
            .body("name", equalTo("John Doe"));
    }
}

💡 Copilot saves time by auto-suggesting API endpoints, headers, and validation rules!


🔎 3. Debugging and Fixing Flaky Tests

SDETs often struggle with flaky tests due to timeouts, race conditions, or unreliable locators.

Before Copilot: You manually inspect logs and experiment with fixes.

With Copilot: Just ask Copilot Chat:

“Why is my Selenium test failing due to ElementNotInteractableException?”

Example: Copilot suggests adding an explicit wait to resolve the issue.

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

def test_wait_for_element():
    driver = webdriver.Chrome()
    driver.get("https://example.com")
    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "submit"))).click()

Problem solved in seconds!


🎯 4. Auto-Generating Test Data

Manually creating test data is slow and error-prone. Copilot can generate:
Random usernames & passwords
Valid email formats
Data-driven test inputs

Example: Auto-Generating Test Data in Python

import random
import string

def generate_random_email():
    return ''.join(random.choices(string.ascii_lowercase, k=8)) + "@test.com"

print(generate_random_email())

Use Copilot to create bulk test data for automation frameworks!


📢 5. Writing Custom Assertions for Test Frameworks

SDETs frequently write and reuse custom assertions.

Example: Writing a Custom Assertion in Cypress

Cypress.Commands.add('verifyText', (selector, expectedText) => {
    cy.get(selector).should('have.text', expectedText);
});

// Usage:
cy.verifyText('.welcome-msg', 'Welcome, Test User!');

💡 Copilot suggests common assertions and best practices based on industry standards!


🔮 The Future: AI-Driven Test Automation

GitHub Copilot is not just a code generator for us – it’s an AI-powered SDET assistant.

Here’s how we as SDETs can take automation to the next level:

  1. Use Custom Instructions: Configure Copilot to follow your team’s coding standards for test automation.
  2. Leverage Copilot Edits: Auto-refactor flaky tests across multiple files.
  3. Pair Copilot with AI Models: Use GPT-4o for debugging suggestions and Claude 3.5 for detailed explanations.
  4. Voice-Based Test Scripting: Talk to Copilot to generate test automation code hands-free.

🎯 Key Takeaways

GitHub Copilot Free is available in VS Code – no subscription required.
SDETs can use it for test automation, debugging, and refactoring.
Boost productivity by letting AI handle repetitive coding tasks.
Free tier includes 2,000 code completions & 50 chat requests per month.

🔗 Get Started Today: Enable GitHub Copilot in VS Code and transform how you write test automation scripts.

Let me know how you’re using Copilot in your SDET workflows! 🚀💡

Article Contributors

  • Gaurav Khurana
    (Author)
    Sr. Test Consultant, Microsoft

    With 14+ years of experience, Gaurav shares insightful testing tips in a simple and effective way through Udzial Means Share. He specializes in Automation, Azure DevOps, Playwright, Selenium, and API testing. As a YouTuber and Blogger, he actively contributes to the testing community, making complex topics easy to understand.

  • Ishan Dev Shukl
    (Coauthor)
    SDET Manager, Nykaa

    With 13+ years in SDET leadership, I drive quality and innovation through Test Strategies and Automation. I lead Testing Center of Excellence, ensuring high-quality products across Frontend, Backend, and App Testing. "Quality is in the details" defines my approach—creating seamless, impactful user experiences. I embrace challenges, learn from failure, and take risks to drive success.

Subscribe to our QABash Weekly Newsletter

Dominate – Stay Ahead of 99% Testers!

Leave a Reply

Scroll to Top