Case Study: User Change Password Automated Test

Completing this simple automated test well is not as easy as some might think.

Zhimin Zhan
6 min readJul 11, 2022

--

A repost of my daughter’s article with permission. I added the review part. This is also included in my “How to in Selenium WebDriver” series.

This article will provide four approaches to One Test Automation Scenario Interview Question that Most Candidates Failed.

“Change a User’s Password”

Table of Contents:
· Be aware of Side-Effect of Test Execution
· 1. Change the password back
· 2. Starting with a newly created user
· 3. Save the password-change status into a file
· 4. Database Reset
· Review (by Zhimin)

Be aware of Side-Effect of Test Execution

Unlike Unit Testing, functional testing may have side effects, that is, changing the state of the application or certain data. This test case falls into that category.

After a user changed his password successfully, we cannot use the old password to log in again. The below video (animated GIF) shows the execution of running a change password test twice, then failing the second time.

Run the user-change-password twice. first time: pass; second time: failed

Here I will present four approaches.

1. Change the password back

Once the password has been changed (and verified), immediately change it back to the previous password.

Test Script:

# try running this case twice
it "[1] User can change password, Change it back" do
sign_in("james@client.com", "test01")
click_avatar_menu("Edit Profile")
edit_user_page = EditUserPage.new(browser)
edit_user_page.enter_password("newpass")
edit_user_page.enter_confirm_password("newpass")
edit_user_page.click_save
relogin("james@client.com", "newpass") # reset the user's password back
click_avatar_menu("Edit Profile")
edit_user_page = EditUserPage.new(browser)
edit_user_page.enter_password("test01")…

--

--

Zhimin Zhan

Test automation & CT coach, author, speaker and award-winning software developer. Help teams succeed with Agile/DevOps by implementing real Continuous Testing.

Recommended from Medium

Lists

See more recommendations