Test automation click might not completely simulate an actual human click
I have been working at this client where i am opportuned to use cucumber, watir-webdriver and i came across this problem today. The application i am testing is an e-commerce site and i am writing test for a page on which i click on an item and the item appears on the shopping basket area of the site.
My code look like
[code]
def select_item(item_name) @browser.li(:text => /#{item_name}/).link(:class_name => “addOptions”).click Watir::Wait.until { @browser.img(:alt => /#{item_name}/).exists? } end
As you can i am waiting for an image which is the icon that represent the item i am buying to appear on the shopping basket. I get this error when the test click on the item
[code]
Element is not currently visible and so may not be interacted with (Selenium::WebDriver::Error::ElementNotDisplayedError)
And on visual inspection, i can see that the item is being added into the shopping basket, this led me to inspect the source to look for any event that might need to be triggered and i found an “onclick”
To supress this error i had to manually trigger the onclick event by inserting
[code]
@browser.li(:text => /#{item_name}/).link(:class_name => “addOptions”).fire_event(“onlick")
My test now run reliably. What you can take from this is that even though the UI seems to be doing the right things, there might so event needed for the page logic to behave as expected.
Tags:
You Might Also Like
Tests automation, a crucial part of Continuous Integration and Continuous Delivery
Why automated tests, not just automated builds, are what make Continuous Integration and Continuous Delivery actually work.
June 15, 2018
Should API test and UI Acceptance Tests be written in the same programming language?
Why writing API tests and UI acceptance tests in the same language (Groovy, Geb, Spock) reduces duplication, silos, and maintenance cost.
August 24, 2017
Testing an Asynchronous System - Part 2
Writing automated negative-path tests for a CQRS, event-driven system where failed writes never appear in the read side.
January 6, 2017
