ChatGPT — RIP Testers — Part 2

Devil’s Advocate
4 min readMar 9, 2023

My previous post on the impact of ChatGPT on testing (https://medium.com/@bigfundu/chatgpt-rip-testers-c318c41e3f35) had a lot of good observations as responses posted by many from the QA field. But it was a quick post just to highlight what ChatGPT can do for an experienced tester.

I thought I will do a follow-up post on automation testing also.

Me: A user registration page takes in a user id, mobile number and sends OTP to user for validating the registration. Once the registration is complete, the user has to login. Once login is successful, the user will be lead to a dashboard page. Can you please generate the functional test cases for such the registration and login pages?

ChatGPT: Sure, I can help you generate some functional test cases for the registration and login pages:

Registration Page:

Verify that user can enter a valid user ID (e.g. alphanumeric, 8–20 characters).

Verify that user can enter a valid mobile number (e.g. 10 digits).

Verify that the OTP is sent to the user’s mobile number.

Verify that the user cannot proceed without entering a valid user ID and mobile number.

Verify that the user cannot proceed without entering the correct OTP.

Verify that the user cannot use the same user ID and mobile number to register again.

Login Page:

Verify that the user can enter a valid user ID and password to log in.

Verify that the user cannot log in with an incorrect user ID or password.

Verify that the user cannot access the dashboard page without logging in first.

Verify that the user is redirected to the dashboard page upon successful login.

Verify that the user can click on a “Forgot Password” link to reset their password if they forget it.

Verify that the user is automatically logged out after a certain period of inactivity.

Dashboard Page:

Verify that the user can see relevant information (e.g. account details, balance, etc.).

Verify that the user can perform necessary actions (e.g. deposit, withdraw, transfer, etc.).

Verify that the user can log out and is redirected back to the login page.

Verify that the user cannot access the dashboard page without logging in first.

These are some of the functional test cases that you can use to ensure that your registration and login pages are working properly.

I followed up by asking the tool to generate some automation test code using Selenium.

Me: Can you generate the selenium test cases for these test cases?

ChatGPT: Sure, I can provide you with an example set of Selenium test cases for the functional test cases we discussed earlier:

Registration Page:

Test that a valid user ID can be entered and saved.

@Test
public void testValidUserID() {
WebElement userID = driver.findElement(By.id("userID"));
userID.sendKeys("myUserID123");
Assert.assertEquals("myUserID123", userID.getAttribute("value"));
}

Test that a valid mobile number can be entered and saved.

@Test
public void testValidMobileNumber() {
WebElement mobileNumber = driver.findElement(By.id("mobileNumber"));
mobileNumber.sendKeys("1234567890");
Assert.assertEquals("1234567890", mobileNumber.getAttribute("value"));
}

Test that the OTP is sent to the user’s mobile number.

@Test
public void testOTPSent() {
WebElement sendOTPButton = driver.findElement(By.id("sendOTP"));
sendOTPButton.click();
// add wait for OTP to be sent and validate that OTP is received
//...
//...
//assert that the OTP is received
Assert.assertEquals("123456", receivedOTP);
}

Test that the user cannot proceed without entering a valid user ID and mobile number.

@Test
public void testInvalidUserIDMobileNumber() {
WebElement userID = driver.findElement(By.id("userID"));
userID.sendKeys("");
WebElement mobileNumber = driver.findElement(By.id("mobileNumber"));
mobileNumber.sendKeys("");
WebElement registerButton = driver.findElement(By.id("register"));
registerButton.click();
WebElement errorElement = driver.findElement(By.id("errorMessage"));
Assert.assertEquals("Please enter a valid user ID and mobile number.", errorElement.getText());
}

Test that the user cannot proceed without entering the correct OTP.

@Test
public void testInvalidOTP() {
WebElement userID = driver.findElement(By.id("userID"));
userID.sendKeys("myUserID123");
WebElement mobileNumber = driver.findElement(By.id("mobileNumber"));
mobileNumber.sendKeys("1234567890");
WebElement sendOTPButton = driver.findElement(By.id("sendOTP"));
sendOTPButton.click();
// add wait for OTP to be sent and enter incorrect OTP
//...
//...
WebElement otpInput = driver.findElement(By.id("otp"));
otpInput.sendKeys("12345");
WebElement registerButton = driver.findElement(By.id("register"));
registerButton.click();
WebElement errorElement = driver.findElement(By.id("errorMessage"));
Assert.assertEquals("Please enter the correct OTP.", errorElement.getText());
}

The tool went on to create more Selenium code. I am not including them for the size of the post will keep increasing.

Adding more prompts like adding security test cases is very logical and easily generated by the tool. This might look like a trivial test case listing but it is not. It is the capability of the tool that has to be looked at.

My main points from these two posts are:

  • Tools like ChatGPT can replace the efforts of 2–3 people with 1 person who can effectively generate the manual test cases, automation test cases along with automation test code also
  • Prompt Engineering will be a new job replacing many roles in the QA domain

I repeat: ‘Testing as we know it now’ will change and is already changing with the introduction of AI tools like ChatGPT and Github Copilot.

--

--

Devil’s Advocate

Seeker for life. Looking to make technology simpler for everyone.