Search code examples
selenium-webdriverwatirgeckodriverselenium-firefoxdriver

Watir: How to wait until a div is no longer visible


I am running some BDD tests with Cucumber, Watir and the Selenium Driver. One of the tests I need to run is to ensure that a loading div disappears once the page is loaded, and then that a search box appears.

I have this line : @browser.text_field(placeholder: /Search/).wait_until(&:present?) which should wait until the search box is visible, but it doesn't. I want to then wait_until the div id='loader' is not visbile.

I don't know how to express this with Watir.


Solution

  • Waiting for something to disappear can be done by using #wait_while:

    browser.div(id: 'loader').wait_while(&:present?)