Module: Watir::Wait
- Defined in:
- lib/watir-webdriver/wait.rb
Defined Under Namespace
Classes: TimeoutError
Constant Summary
- INTERVAL =
0.1
Class Method Summary (collapse)
-
+ (Object) until(timeout = 30, message = nil, &block)
Wait until the block evaluates to true or times out.
-
+ (Object) while(timeout = 30, message = nil, &block)
Wait while the block evaluates to true or times out.
Class Method Details
+ (Object) until(timeout = 30, message = nil, &block)
Wait until the block evaluates to true or times out.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/watir-webdriver/wait.rb', line 15 def until(timeout = 30, = nil, &block) end_time = ::Time.now + timeout until ::Time.now > end_time result = yield(self) return result if result sleep INTERVAL end raise TimeoutError, (timeout, ) end |
+ (Object) while(timeout = 30, message = nil, &block)
Wait while the block evaluates to true or times out.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/watir-webdriver/wait.rb', line 31 def while(timeout = 30, = nil, &block) end_time = ::Time.now + timeout until ::Time.now > end_time return unless yield(self) sleep INTERVAL end raise TimeoutError, (timeout, ) end |