Module: Watir::Wait
- Defined in:
- lib/watir-webdriver/wait.rb
Defined Under Namespace
Classes: TimeoutError
Constant Summary collapse
- INTERVAL =
0.1
Class Method Summary collapse
-
.until(timeout = nil, message = nil, &block) ⇒ Object
Waits until the block evaluates to true or times out.
-
.while(timeout = nil, message = nil, &block) ⇒ Object
Wait while the block evaluates to true or times out.
Class Method Details
.until(timeout = nil, message = nil, &block) ⇒ Object
Waits until the block evaluates to true or times out.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/watir-webdriver/wait.rb', line 24 def until(timeout = nil, = nil, &block) timeout ||= Watir.default_timeout wait(timeout) do result = yield(self) return result if result sleep INTERVAL end raise TimeoutError, (timeout, ) end |
.while(timeout = nil, message = nil, &block) ⇒ Object
Wait while the block evaluates to true or times out.
46 47 48 49 50 51 52 53 54 |
# File 'lib/watir-webdriver/wait.rb', line 46 def while(timeout = nil, = nil, &block) timeout ||= Watir.default_timeout wait(timeout) do return unless yield(self) sleep INTERVAL end raise TimeoutError, (timeout, ) end |