I am very new to Vatira.
I have some Ruby / Watir code that should determine if an element exists, and if so, click it, if not, click another element. Both elements appear every time. Unfortunately, nothing I tried works.
if browser.contains_text("/media/images/icons/reviewertools/editreview.jpg") then browser.image(:src => "/media/images/icons/reviewertools/editreview.jpg").click else browser.image(:src => "/media/images/icons/reviewertools/savereview.jpg").click end
As a result, this fails: "Unable to find element using {: src =>" /media/images/icons/reviewertools/savereview.jpg "} (Watir :: Exception :: UnknownObjectException)"
He had to click /editreview.jpg, which was visible.
I also tried:
if browser.image("/media/images/icons/reviewertools/savereview.jpg").exists then browser.image(:src => "/media/images/icons/reviewertools/savereview.jpg").click
and:
if browser.image("/media/images/icons/reviewertools/savereview.jpg").exists?
Note that NONE, in these cases, either detects an item or fails to do so, executes an else clause.
Please respond with specific examples of code for your suggestions.
John hammink
source share