Skip to content

BrowserModule::Wait

jfinkhaeuser edited this page Dec 17, 2014 · 3 revisions

BrowserModule::Wait

The wait module combines Watir's ability to wait for something to happen with the functionality of the find module. In particular, it exposes corresponding wait functions for all existing find functions, e.g. wait_all, multi_wait, etc.

The syntax for calling the wait functions is the same as for find functions, but a few more options may be passed.

If wait functions do not find the elements according to their parameters and selectors, they will produce an error using the world error module.

Wait Options

  • timeout - a timeout in seconds, defaults to 10.
  • condition - one of :while or :until, defaults to wait :until.
  • screenshot - a boolean flag determining whether a screenshot should be taken on failure.

Wait Selectors

Selectors for wait functions are identical to selectors for find functions, with one crucial difference: the default is to filter only by present elements (i.e. :filter_by defaults to :present?), as that is the most common usage when waiting for something on a web page.

Examples

browser.wait(:timeout => 5, :text => "Hello World")
browser.wait(:timeout => 5, :text => /Hello World/i)
browser.wait(:timeout => 10, :id => "foo", :condition => :while)
browser.multi_wait_all(:div, :span)