How to Use ChatGPT for Test Automation

Test automation is an important task in software development required for the rapid execution of test cases to check reproducibility, consistency and early error detection. One of the commonly used and handy AI, ChatGPT, is a language model developed by OpenAI. It has numerous functionalities and helps efficiently perform tasks like test automation. ChatGPT can be integrated into the test automation toolkit for data validation, streamlining test case generation and simplifying complex testing scenarios. 

Understanding ChatGPT

For a better output from ChatGPT for automation testing, it is important to begin by understanding its function mechanism. It is divided into three parts:

  • Training: It is trained through numerous resources where it learns language rules, patterns and context. 
  • Language understanding: It analyses the prompt and understands the context behind the input. 
  • Text generation: The text response is generated based on understanding from the previous step. 

Your AI/ML Career is Just Around The Corner!

AI Engineer Master's ProgramExplore Program
Your AI/ML Career is Just Around The Corner!

Benefits of Chat GPT for Test Automation

The AI model serves multiple benefits in test automation, such as: 

  • Rapidly generates test cases 
  • Generates ideas and assumptions for queries 
  • Improves test coverage 
  • Efficient for generalized testing 
  • Provides standardized test case formats 
  • Saves time and cost
  • Enhance productivity 
  • Integrability with automation frameworks 

Examples of Using ChatGPT for Testing Automation 

ChatGPT for automation testing can be done in the following multiple scenarios, among numerous others:

Writing Test Scripts with ChatGPT

ChatGPT can generate test scripts while independently assuming different scenarios for ChatGPT test automation. The complete operation of the same was evident when we entered the test query “create a test script with 2 assumed methods to open a school website and download the brochure”. ChatGPT assumed two methods, one to directly download the brochure through the available button while another to navigate through the site and reach the desired location to download it. 





Generating Test Data

ChatGPT test automation involves generating test data. Here we generated test data with the prompt “generate test data of 10 patients in a tabulated manner for researching the gut microbiome of patients with comorbid conditions like diabetes, CVD. Ensure considering all the relevant parameters”. ChatGPT generated the test data considering multiple directly associated parameters. Further, it also informed us about the random and unreal generation of data and the importance of taking real data. 




Your AI/ML Career is Just Around The Corner!

AI Engineer Master's ProgramExplore Program
Your AI/ML Career is Just Around The Corner!

Using ChatGPT to Change and Fix Code

Here we assume a simulation to indicate cytoskeleton (biologically cellular structure) movement. This structure is responsible for the movement of cells, such as immune cells that fight off infection in our body. The prompt to fix the code was, “I have a Python function to simulate the cytoskeleton movement. But the simulation seems to be unable to portray actin and myosin filament accurately. How to fix the code for this?” ChatGPT test automation fixed the error by introducing random movement and time steps and improving the interaction between the two. 




Design Sample Test Cases 

The blood groups of humans exhibit multiple alleles, meaning the blood group can have different genotypes. We consider this case to predict the blood group of a child. The prompt for ChatGPT for test automation is “Test cases for testing the probability of the presence of a specific blood group in a child. Consider a real-world scenario where the blood group can have two genotypes”.






Your AI/ML Career is Just Around The Corner!

AI Engineer Master's ProgramExplore Program
Your AI/ML Career is Just Around The Corner!

Format Data

DNA sequences are stored in various formats. Our query was based on FASTA and GenBank format. The former provides only the DNA sequence, while the latter is associated with multiple other information. In ChatGPT test automation for data formatting, the prompt was “Write a program in Python and R to convert the DNA and protein sequences from FASTA format to GenBank format simultaneously.” ChatGPT provides a separate program for each programming language for data/sequence manipulation using specific libraries. 








Your AI/ML Career is Just Around The Corner!

AI Engineer Master's ProgramExplore Program
Your AI/ML Career is Just Around The Corner!

Test Result Analysis

Mutations are changes in genetic sequences. Concerning their immense importance, we request ChatGPT for automation testing to compare the mutation frequency. Here is the prompt for the same “Analyze the results of two random DNA sequences with different mutation rates. State the frequency of different types of mutations in it”. 






Your AI/ML Career is Just Around The Corner!

AI Engineer Master's ProgramExplore Program
Your AI/ML Career is Just Around The Corner!

Challenges and Limitations of Using ChatGPT for Test Automation

Though ChatGPT for test automation is effortless, certain limitations are associated with it. Here are the significant ones enlisted: 

  • ChatGPT has encountered loads of data in training. However, it lacks expertise in any specific domain. It leads to a lack of accuracy. 
  • It might misinterpret prompts.
  • The assumptions and ability to simulate scenarios or conditions are limited. 
  • An inability to infer from ambiguous queries.
  • Responses are more generalized
  • Providing confidential information concerning experiments and innovation is risky 
  • The inability to actually interact with real experiments or software limits its capability to adapt.
  • Not suitable for complex test scenarios 
  • Coding and factual errors are seen without warning 
  • Human validation is required to add to the already available tasks

Best Practices for Utilizing ChatGPT in Test Automation

Here are some tips to overcome the multiple challenges that a user may face while performing test automation:

  • Be specific with keywords 
  • Use ChatGPT itself to generate the ideas 
  • Ensure manual validation of its query with a focus on each line and step 
  • Avoid sharing sensitive information or idea 
  • Focus on the methodology of ChatGPT to develop answers and modify them accordingly 
  • Ensure to provide context about your queries 
  • Provide background information, specifically for the concerned domain
  • Integrate ChatGPT with traditional automation toolkit
  • Carefully consider possible biases by ChatGPT and check the results accordingly 


Efficient test automation requires complete knowledge of the AI chatbot used for the endeavor. Enroll in Post Graduate Program in AI and Machine Learning that will help you learn in-demand skills such as machine learning, deep learning, NLP, computer vision, reinforcement learning, generative AI, prompt engineering, ChatGPT, and many more. This post graduation program provides in-depth knowledge, hands-on experience and expert guidance besides the valuable certificate to showcase your dedication towards learning.  

Choose the Right Program

Unlock the potential of AI and ML with Simplilearn's comprehensive programs. Choose the right AI/ML program to master cutting-edge technologies and propel your career forward.

Program Name

AI Engineer

Post Graduate Program In Artificial Intelligence

Post Graduate Program In Artificial Intelligence

Geo All Geos All Geos IN/ROW
University Simplilearn Purdue Caltech
Course Duration 11 Months 11 Months 11 Months
Coding Experience Required Basic Basic No
Skills You Will Learn 10+ skills including data structure, data manipulation, NumPy, Scikit-Learn, Tableau and more. 16+ skills including
chatbots, NLP, Python, Keras and more.
8+ skills including
Supervised & Unsupervised Learning
Deep Learning
Data Visualization, and more.
Additional Benefits Get access to exclusive Hackathons, Masterclasses and Ask-Me-Anything sessions by IBM
Applied learning via 3 Capstone and 12 Industry-relevant Projects
Purdue Alumni Association Membership Free IIMJobs Pro-Membership of 6 months Resume Building Assistance Upto 14 CEU Credits Caltech CTME Circle Membership
Cost $$ $$$$ $$$$
Explore Program Explore Program Explore Program


1. Can ChatGPT replace manual testing entirely?

Despite numerous helpful responses in different scenarios, the accuracy and efficiency of ChatGPT are questionable due to significant challenges and limitations. Hence, chat gpt for automation testing will not replace manual testing entirely. 

2. How accurate does ChatGPT generate the test scripts?

The lack of accuracy in its responses may not ensure complete correctness. The reliability of test scripts varies depending on the scenario and complexity of the query. 

3. Can ChatGPT handle complex user interactions and edge cases?

ChatGPT has several limitations, and the inability to handle complex user interactions and edge cases is one among them. 

4. Is prior knowledge of programming or AI required to use ChatGPT for test automation?

A good understanding of programming languages is crucial for a professional career in test automation. It aids in various aspects. 

5. Can ChatGPT be integrated with existing test automation frameworks and tools?

It can be integrated with frameworks like Selenium, Puppeteer and multiple others. 

About the Author

Sneha KothariSneha Kothari

Sneha Kothari is a content marketing professional with a passion for crafting compelling narratives and optimizing online visibility. With a keen eye for detail and a strategic mindset, she weaves words into captivating stories. She is an ardent music enthusiast and enjoys traveling.

View More
  • Disclaimer
  • PMP, PMI, PMBOK, CAPM, PgMP, PfMP, ACP, PBA, RMP, SP, and OPM3 are registered marks of the Project Management Institute, Inc.