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 = 30, message = nil, &block) ⇒ Object
Waits until the block evaluates to true or times out.
-
.while(timeout = 30, message = nil, &block) ⇒ Object
Wait while the block evaluates to true or times out.
Class Method Details
.until(timeout = 30, message = nil, &block) ⇒ Object
Waits until the block evaluates to true or times out.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/watir-webdriver/wait.rb', line 21 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 |
.while(timeout = 30, message = nil, &block) ⇒ Object
Wait while the block evaluates to true or times out.
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/watir-webdriver/wait.rb', line 44 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 |