Can ChatGPT Write Testing Automation for Tools Like Selenium, Cypress, and Playwright?

ChatGPT and Automation Testing

With over one million users in only five days, ChatGPT is the newest innovation in natural language processing that has taken over the internet by storm.

The free AI chatbot, just recently launched, gained instant notoriety owing to its capacity to answer questions, clearly explain ideas, or carry out challenging tasks like composing a song or explaining complex mathematics. 

Given that ChatGPT can create test cases in various frameworks and languages, there are significant implications for automated testing for online and mobile app developers. 

ChatGPT: Uses and Limitations

So let’s read about used to, uses and limitations of ChatGPT and investigate the options.

What is ChatGPT

  • ChatGPT, developed by OpenAI, is a substantial language model that was improved using supervised and reinforcement learning on huge datasets. ChatGPT examines the data using algorithms to look for patterns that aid in its comprehension of natural language and word use. Because it is a dialogue-based paradigm, it is intended for back-and-forth communication. If the system doesn’t deem it objectionable, you can ask ChatGPT whatever you like.
  • ChatGPT is capable of generating insightful and pertinent comments, frequently outlining the rationale behind each one. To conduct a coherent dialogue, it can also recall its prior replies. You can ask it to generate anything from writing a fictional novel to questions about molecular biology.

What is Testing Automation?

  • Automation Testing involves writing code (usually in a scripting or programming language) to automatically execute test cases and validate if the application under test behaves as expected. 
  • This helps to reduce the time and effort needed for manual testing, increase the speed and accuracy of testing, and improve the overall quality of the software.
  • Testing Automation can be used for an application’s functional, regression, and performance testing.
  • The Test Code interacts with the application by simulating user actions and verifying the output. Popular languages for automation testing include Java, Python, Ruby, JavaScript, and C#.

Can ChatGPT be Used to Write Testing Automation?

  • One of ChatGPT’s most intriguing aspects is its ability to produce correctly structured and pertinent code from a straightforward natural language request. It may leverage several built-in packages across various languages and create code in various languages. The logical inquiry that follows is whether ChatGPT can provide code for automated testing.
  • Right now, the answer is “Yes, sort of.” Despite that, it should be noted that it cannot replace the role of skilled programmers, professors, or mentors. It may be a fantastic learning tool, but it should be combined with other materials and advice from seasoned programmers.
  • However, this is only the beginning of being able to create code that looks accurate. In a perfect world, one would give ChatGPT a description of the test to create, it would be aware of every aspect of the website version being tested, and it would provide flawless, executable code that doesn’t require any alterations. Not right now, according to ChatGPT. However, what it is capable of is still rather remarkable.

Examples of Using ChatGPT for Automation Testing

  1. Generate UI Automation Script for Cypress/ Javascript

Prompt: “Write Cypress/ Javascript code for opening the URL of the site


oU5f UiN8L0SOjZf1pjKJ3eptHVMLgnY6Kx4tSQRYnVEJvPeQQnb3cq8T5sKkgkEqwFCO0c9qtVu
  1. Application of Web Testing using Selenium
  • Consider that you wish to plan the test automation for a website called, which you have developed some features.
  • In these situations, you may utilize GPT by providing information about the functional components and how they are used, then asking it to produce a test plan.

Prompt: is a website. Prepare a test plan for an automation test to carry out the following validation on the website: Open Success if the page loads with the title ‘TestGrid TestOS – The first-choice OS for End-to-End Testing’”


  • lIGEOlJAOqTuUH7SuTjseSLe2zCUK44xFuQhtsiMu MEfmMpAAq1EEUETm3oiuxsejgVp8Dkn5a rq21I9HxdHQz5
  1. ChatGPT may be used to format any data and get it ready for any other format.

    Consider the scenario where you need the test plan to be in a format that will make it simple for you to input into a bug-tracking system like Jira or Github.

In this situation, you may use ChatGPT by prompting further in the same thread:

Prompt:  “Prepare test case table to enter into Jira tickets ”



Limitations of ChatGPT

  • Errors in the code: Since it is still in the Beta phase, chatGPT code may have errors or be less efficient, and it may not always function properly due to a lack of understanding of the task’s unique context or needs. Before utilizing the produced code in any project, it is crucial to check and test it properly.
  • Factual mistakes: Since ChatGPT was trained on a sizable amount of text data, it is likely that the factual mistakes or disinformation that were included in the training data ended up in the model.
  • Lack of domain expertise: Although ChatGPT may produce language that resembles human writing, it could fall short in some areas of particular subject knowledge or expertise compared to a human expert.
  • Biases: The model may have picked up biases from the enormous amount of text data gathered from the internet it was trained on. As a result, offensive or inappropriate content may be produced.


  • Companies may automate repetitive operations and get deeper insights into their test data by utilizing AI, which makes it simpler to recognize and troubleshoot problems, forecast and avoid mistakes, and enhance overall quality.
  • Though there are certain drawbacks to test automation utilizing GPT, with the correct strategy and test cases, it can be a potent tool that aids teams in streamlining their testing procedure and eventually producing better products.