Case Study: User Change Password Automated Test
Completing this simple automated test well is not as easy as some might think.
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.
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.
# try running this case twice
it " User can change password, Change it back" do
click_avatar_menu("Edit Profile") edit_user_page = EditUserPage.new(browser)
edit_user_page.click_save relogin("email@example.com", "newpass") # reset the user's password back
edit_user_page = EditUserPage.new(browser)