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
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:
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: