Module: Watir::Wait
Defined Under Namespace
Classes: TimeoutError
Instance Method Summary collapse
-
#until(timeout = 60, &block) ⇒ Object
Wait until the block evaluates to true or times out.
-
#while(timeout = 60, &block) ⇒ Object
Wait while the block evaluates to true or times out.
Instance Method Details
#until(timeout = 60, &block) ⇒ Object
Wait until the block evaluates to true or times out.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/watir-classic/wait.rb', line 14 def until(timeout = 60, &block) end_time = ::Time.now + timeout until ::Time.now > end_time result = yield(self) return result if result sleep 0.1 end raise TimeoutError, "timed out after #{timeout} seconds" end |
#while(timeout = 60, &block) ⇒ Object
Wait while the block evaluates to true or times out.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/watir-classic/wait.rb', line 29 def while(timeout = 60, &block) end_time = ::Time.now + timeout until ::Time.now > end_time return unless yield(self) sleep 0.1 end raise TimeoutError, "timed out after #{timeout} seconds" end |