0
votes
require 'watir'
b=Watir::Browser.new
b.goto 'www.xyz.com'
b.maximize
b.label(:text, "Car Make").parent.spans[1].click
b.element(tag_name: 'md-option', text: "BMW").when_present.click

The above code works fine when I write for watir-classic, but when I write above code for watir-webdriver, the visibility checking is stopping me to click b.label(:text, "Car Make").parent.spans[1].click this element, Is there any way Can I cancel out this visibility checking in watir webdriver? The code which I have written for watir-webdriver follows,

require 'watir-webdriver'
require 'watir-scroll'
b=Watir::Browser.new :chrome
b.goto 'www.xyz.com'
b.window.maximize
b.label(:text, "Car Make").parent.spans[1].click
b.element(tag_name: 'md-option', text: "BMW").when_present.click
1
at one point, watir was 1 based for indexes, but we moved to 0 based. Just to be sure that's not it.. you are trying to click the second span below the parent, correct?Chuck van der Linden

1 Answers

1
votes

There is no option in Watir-Webdriver for disabling the visibility checks. For testing, it is actually better that you do not interact with non-visible elements.

The best solution is really to make the label/span visible before you click it. Perhaps you just need to wait for it to be present:

b.label(:text, "Car Make").parent.spans[1].when_present.click

If you really do want to bypass the visibility check, you could fire the click event directly. Note that you may need to fire multiple events if your element is expecting more than just a click:

b.label(:text, "Car Make").parent.spans[1].fire_event(:onclick)