#34: Client Membership (Multiple User Sign in and out)
Use reusable helper functions for a repeated common set of test steps.
This article is one of the “Selenium Training Workbook” series, a set of bite-sized exercises. While each exercise is independent, it may require knowledge and practices covered in previous episodes.
Learning Objectives
Multiple users log in and out.
Review: Extract to Function & Extract to Page refactoring
Review: Automate transformed web controls (the previous episode)
Test Design
The business user signs in
Go to its business setting page, set to member access only
The business user signs out
An existing customer signs in
Apply for the membership for one business
The customers signs out
The business user signs in (again)
Find the application for the membership
Approve it, e.g. setting the expiry date
The business signs out
The customer signs in (again)
Verify his membership
Test Data (Login) :
Site URL: https://whenwise.agileway.net
Login (Business): tennis@biz.com
Login (Customer): james@client.com
Password: test01
Knowledge Point: Use reusable helper functions for repeated common set of test steps.
For this test case, there are at least 4 user sign-ins (two different accounts).
Log in as the customer:
driver.find_element(:id, "email").send_keys("james@client.com")
driver.find_element(:id, "password").send_keys("test01")
driver.find_element(:id, "login-btn").click
Login as the business user:
driver.find_element(:id, "email").send_keys("tennis@biz.com")
driver.find_element(:id, "password").send_keys("test01")
driver.find_element(:id, "login-btn").click
Also, at least three user sign-outs, the same regardless of account.
driver.find_element(:id, "avatar").click
sleep 1
driver.find_element(:id, "logout-link").click
Now imagine, with 7 segments of these in one test script. Not tidy, right?
A better way is to extract the above into functions.
Keep reading with a 7-day free trial
Subscribe to AgileWay’s Test Automation & Continuous Testing Blog to keep reading this post and get 7 days of free access to the full post archives.