21 Verify Logged out Properly & Run the same against against two different browsers
How to run tests across different browsers in Selenium WebDriver
Learning Objectives
Verify a simple and obvious operation, such as logout
Browser navigation in Selenium WebDriver
Run the same automated test against different browsers, e.g. Chrome, Firefox, etc. Get concept of Cross Browser Testing
Test Execution set up for different browsers
Test Case #21
In the previous session, we wrote a simple user login test (the simplest and the most common one).
it "Login ok" do
driver.find_element(:link_text, "SIGN IN").click
driver.find_element(:id, "email").send_keys("yoga@biz.com")
driver.find_element(:id, "password").send_keys("test01")
driver.find_element(:xpath, "//input[@id='remember_me']/../span").click
driver.find_element(:id, "login-btn").click
expect(page_text).to include("You have signed in successfully")
visit("/sign-out") # logout
end
We verified “Logged in” by checking the text You have signed in successfully
. But did we verify the logged out? NO.
Test Design
There are several ways to verify user logout. Here I propose one (might sound complex, but for education purposes).
The user Logs out (either click the logout link or enter a direct
/sign-out
URL)Clicks the back button in the browser to navigate back to its previous page, showing the user is still logged in (which is fine)
Click the refresh button
Should be on the login page (as signed out), verify by the current web address (URL)
Task 1: Basic browser navigation
Browser back
driver.navigate.back
Refresh the browser
driver.navigate.refresh
Get the current URL (web address)
driver.current_url
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.