4 Ways to Use ChatGPT in Low-code Test Automation
4 Ways to Use ChatGPT in Low-code Test Automation Darrel Farris May 18, 2023
4 Ways to Use ChatGPT in Low-code Test Automation
To say that people are excite about ChatGPT, and productive AI more loosely, would be an understatement. Few communities are embracing this engineering with as much ebullience as the quality engineering creation, where passionate tester are quickly finding new ways to tackle big language framework to improve product quality and the customer experience. & nbsp;
The mabl team has long recognize the potential of intelligence to pressurize test automation, and we share the QE community ’ s excitement for emerging tools like ChatGPT for automate software testing. For the odd mabl user, there are a number of ways to use low-code examination automation and ChatGPT for fun and productivity today.
Harnessing the Power of Intelligence + Low-code Test Automation
Low-code and intelligence are natural partners in test automation. Both technologies can be harnessed to elevate the impact of software prove by helping character professionals and developer reduce rote employment. Less rote employment means that everyone on your team can rest focused on building innovative, high-quality software that drives concern success.
Create Scenarios for Data-Driven Testing
Have you ever wanted to increasetest coverageby generating naturalistic data? Though mabl already back this through ourintegration, ChatGPT can help you render a greater volume of realistic information for a wider range of mapping based on your existing testing information. Let ’ s say, for example, that I had a test that signal up for a service using the undermentioned hard-coded values:
First Name: John
Final Name: Doe
Email: john.doe @ acme.com
Street Address: 1600 Pennsylvania Avenue
City: Washington
State: DC & nbsp;
Zip: 20500
Employee ID: 222C01-01
I employ a simple prompting to generate realistic scenario in ChatGPT:
Based on this, generate 10 alternatives in CSV format. Use random value for each field.
First Name: John
Last Name: Doe
Email: john.doe @ acme.com & nbsp;
Street Address: 1600 Pennsylvania Avenue
City: Washington
State: DC & nbsp;
Zip: 20500
Employee ID: 222C01-01
The results were impress; ChatGPT apace yield 10 extra name/address/ID combinations based on the individual representative provided. The examples postdate the same data formatting and varied each field with a random value. But as is much the case, still, it took a few additional prompts to get the exact results I demand:
Convert to CSV format
Display that in code
Randomize the e-mail domains
Add a column for birth appointment (only for good quantity:) & nbsp;
Format birth date like 12-Oct-2023
Once new information was generated, I simply needed to copy/paste the datum into the text editor, relieve the file as a CSV, and upload it into mabl. Once that ’ s done, I had this datatable:
Example datable with ChatGPT-generated scenarios in mabl
The entire process direct precisely a few minutes. Luckily, mabl get it easy to configure tests to use this datatable rather than hard-coded values, which increased test reporting. For even more impact, I introduced greater variation. For example, I desire to add more international scenarios, so I apply the undermentioned prompting:
Append three more alternatives with addresses and phone numbers in Japan and three more with speech and earpiece numbers in the United Kingdom.
And in s, I had an updated dataset that present new variance in the format of zip codes, phone numbers, etc.
`` Lottie '', '' Miller '', '' 456 Elm Street, Chicago, IL 60601, United States '', '' +1 312 345 6789 '', '' 348r2389n33 ''
`` Charlie '', '' Wills '', '' 18 Maplewood Ave, London N11 6FG, United Kingdom '', '' +44 20 8145 6789 '', '' 348p2391t25 ''
`` Charlize '', '' Nakamura '', '' 2-18-25 Kichijoji, Musashino-shi, Tokyo 180-0004, Japan '', '' +81 3 8745 1234 '', '' 348r2392k35 ''
Write JavaScript Snippets
As a former software tester and developer, I appreciate how mabl combines the simplicity of low-code with the control of, which can be utilize to make exam for specialized or advanced scenarios. & nbsp;
ChatGPT does a outstanding job of writing uncomplicated JavaScript from relevant prompts, including common automation use cases such as string manipulation, browser/API interactions, and more. Here are a few prompts I adjudicate:
Write a JavaScript function that navigates back in the browser
Write a JavaScript function that uses a veritable expression to extract the domain from a provided e-mail address
Write a JavaScript function that regress the breadth of the current window
Write JavaScript that returns the current browser edition
Write a JavaScript function that return a appointment plus a specified act of day in a format like December 28th, 1984
This was ChatGPT ’ s response to the final prompt:
function addDaysAndFormat (daysToAdd) {
& nbsp; & nbsp;const today = new Date();
& nbsp; & nbsp;const futureDate = new Date(today);
& nbsp; & nbsp;futureDate.setDate (today.getDate () + daysToAdd);
& nbsp; & nbsp;const monthNames = [
& nbsp; & nbsp; & nbsp; & nbsp;"January", `` February '', "March", "April", "May", "June", "July",
& nbsp; & nbsp; & nbsp; & nbsp;"August", `` September '', "October", `` November '', `` December ''
& nbsp; & nbsp;];
& nbsp; & nbsp;const month = monthNames [futureDate.getMonth ()];
& nbsp; & nbsp;const date = futureDate.getDate ();
& nbsp; & nbsp;const year = futureDate.getFullYear ();
& nbsp; & nbsp;const ordinal = date => {
& nbsp; & nbsp; & nbsp; & nbsp;if (date > 3 & amp; & amp; date < 21) return 'th';
& nbsp; & nbsp; & nbsp; & nbsp;switch (date % 10) {
& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;case 1: return 'st';
& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;case 2: return 'nd';
& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;case 3: return 'rd';
& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;default: return 'th';
& nbsp; & nbsp; & nbsp; & nbsp;}
& nbsp; & nbsp;};
& nbsp; & nbsp;return ` $ {month} $ {engagement} $ {ordinal (date)}, $ {year} `;
}
console.log (addDaysAndFormat (5)); // prints the date 5 days from today in the desired format
Not a bad start!
SUSA automates exploratory testing with persona-driven behavior, catching bugs that scripted automation misses.
It ’ s stimulate to see how ChatGPT and similar creature can be utilize to create machine-driven testing faster and easier for more people. & nbsp;
The possibilities are endless. Just don ’ t forget to follow the callback format when you.
Summarize a Test
ChatGPT is great at summarisation. You can try sum a given mabl test by exporting the tryout measure in YAML formatting and pasting them into ChatGPT with an effective prompt. & nbsp; & nbsp;
I essay this prompt:
Summarize the postdate test free-base on the finish that it is trying to achieve
[pasted YAML from tryout exportation]
ChatGPT reply with the chase:
The test script furnish aims to reach the following goals:The initial results were fairly comprehensive and elaborate, but depending on your organization and motivation, you ’ ll likely need to finetune your results. I used additional prompt to ameliorate the sum-up, such as:
Validate the API test details by visiting the specified URL and logging into the application using the given credentials.Ensure the presence of specific elements in the user interface, such as the `` New trial image '' and the `` playlist_play '' push.Verify the message and functionality of the API test by checking various text fields, tie-in, and elements, such as the `` GET /api/users? page=2 description '', `` Headers '', `` Body '', and `` Pre-request '' links.Inspect the `` Assertions '' and `` Script '' sections of the test, ensuring that the right text is displayed and the functionality is as require, such as the presence of the `` 15. GET Delayed reply model '' exam and the correct affirmation messages.
The tryout hand is designed to ensure that the API tryout is properly set up, with all required component and functionalities work correctly.
Limit that to the top 3 goals
Limit that to 50 words
Say that in slang… I have to share that result:
Yo, this test script is all about: 1) checkin ' if API trial details are nerveless when loggin ' in, 2) makin ' certain those dope UI constituent show up, and 3) givin ' the API test a look-see to confirm it 's all full with the correct message and purpose, ya cognize?
Specifying Selectors for Locating UI Elements
CSS and XPath queries are an extra alternative when locating page elements. If, , and experience fallen short, you can use a CSS or XPath query as a terminal refuge.& nbsp; In these cases, most user rely on Chrome ’ s built-in XPath/CSS search, but ChatGPT provides a useful alternative. & nbsp;
I found this initial prompt quite efficient:
Provide an xpath selector for the `` Start Free Trial '' button in the following HTML & nbsp;
& lt; div & gt;
& lt; p & gt; Achieve fast and reliable end-to-end tryout coverage with 90 % less effort & lt; /p & gt;
& lt; div & gt; & lt; a href= '' https: //www.mabl.com/trial-registration? var=hp_b '' hreflang= '' en '' & gt; Start Free Trial & lt; /a & gt; & lt; a href= '' https: //www.mabl.com/product? var=hp_b '' hreflang= '' en '' & gt; Learn More & lt; /a & gt; & lt; /div & gt;
& lt; /div & gt;
Here was ChatGPT ’ s response:
The XPath selector for the `` Start Free Trial '' button in the give HTML is: & nbsp;
//a [text () = '' Start Free Trial '']
Pretty full! Let ’ s see what ChatGPT thinks about the CSS option:
Use a css query instead
…to which ChatGPT responded with a lesser option based on href.
button.w-button [href= '' https: //www.mabl.com/trial-registration]
A fun experiment: request ChatGPT which approach is better in terms of simplicity, or whether CSS or XPath selectors are better in general. You can engage ChatGPT to assist you with selectors in a general sense, and even have a conversation on the pros and cons of different attack. I started by providing a prompt and an HTML snippet:
Given this html, provide the 5 best selectors for locating the hunting box
[pasted HTML snippet]
ChatGPT responded with 5 options:
Here are 5 selectors that can be used to locate the search box:
input [type=search]: This selector targets any input element with type= '' lookup ''. In this case, it would match the search box input field.
.rm-SearchToggle: This chooser target the lookup button element with class rm-SearchToggle, which is the parent ingredient of the search box stimulus.
.Input.Input_md.SearchBox-InputUQZAW9QXMe-c: This selector targets the search box input directly, using its grade names. It 's a more specific way of targeting the input than using input [type=search].
button [aria-label=Search]: This selector targets the search button element using its aria-label attribute value, which is `` Search ''.
# AppSearch .SearchBox-InputUQZAW9QXMe-c: This selector target the search box input by combining the ID of its parent element (# AppSearch) with the family name of the remark (SearchBox-InputUQZAW9QXMe-c).
Too many choices! So I ask for some assistance in narrowing the leaning down.
Which of those selectors is the most reliable?
Naturally, ChatGPT had an opinion on the topic and still some guidance on best practices…
The near reliable selector to place the lookup box would be input [type=search] because it directly targets the search box input element using its eccentric property, which is specifically designed for search comment. This selector is less likely to modify or be impact by changes to the HTML structure or class names.
However, it 's always a good practice to use multiple picker and consider the context of the search box to insure that the selector will act in different situation. So it 's a good thought to use a combination of selectors to make sure that the search box can be faithfully located
Finally, I require to know if any of the selectors was a really bad idea, so I asked:
Which of the selector is the least true option?
ChatGPT had some solid advice.
The least dependable selector to locate the search box would be .rm-SearchToggle. This chooser point the hunting button element, which is a parent factor of the search box input field. It swear on the assumption that the hunting push will constantly be present and will always be a parent element of the lookup box input. If the HTML construction changes or the search button is take or displace, this picker will no longer employment.
Therefore, it 's not recommended to use this chooser on its own to locate the search box input. Instead, it can be habituate in combination with former chooser to locate the search box reliably.
What ’ s Next?
Like low-code, ChatGPT has the likely to save character contributor time and effort. I hope these experiments inspire you to consider how ChatGPT can support your exam automation scheme. If you discover any approaches that you ’ d like to share with the quality community, connect with us on or!
Quality Engineering Resources
Automate This With SUSA
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.
Try SUSA FreeTest Your App Autonomously
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.
Try SUSA Free