Module: Watir::Wait
Defined Under Namespace
Classes: TimeoutError
Instance Method Summary collapse
-
#until(timeout = 60) {|instance| ... } ⇒ Object
Wait until the block evaluates to true or times out.
-
#while(timeout = 60) {|instance| ... } ⇒ Object
Wait while the block evaluates to true or times out.
Instance Method Details
#until(timeout = 60) {|instance| ... } ⇒ Object
Wait until the block evaluates to true or times out.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/watir-classic/wait.rb', line 20 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) {|instance| ... } ⇒ Object
Wait while the block evaluates to true or times out.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/watir-classic/wait.rb', line 42 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 |