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

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

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

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. Now, ChatGPT for test automation is emerging as a game-changing application.

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. The possibilities of ChatGPT for test automation tools like Selenium, Cypress, and Playwright are sparking interest among developers and QA professionals alike.

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

ChatGPT:

  1. Application of Web Testing using Selenium
  • Consider that you wish to plan the test automation for a website 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: “testgrid is a website. Prepare a test plan for an automation test to carry out the following validation on the website: Open testgrid Success if the page loads with the title ‘TestGrid TestOS — The first-choice OS for End-to-End Testing’”

ChatGPT:

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

  2. 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 ”

ChatGPT:

chatGPT

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.

Conclusion

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.

Source: This article was originally published at testgrid.io/blog/can-chatgpt-write-testing-...