Sha256: 302ec1555c7a758128677d5ae977ed7c3235b4bd6a4377ab8b3fc86a8f91c26b
Contents?: true
Size: 1.42 KB
Versions: 9
Compression:
Stored size: 1.42 KB
Contents
# encoding: utf-8 module Watir module Wait extend self class TimeoutError < StandardError end # Wait until the block evaluates to true or times out. # # @example # Watir::Wait.until(5) { browser.text_field.exists? } # # @param [Fixnum] timeout timeout to wait until block returns true. # @yieldparam [self] instance instance of self. # @raise [TimeoutError] when timeout exceeds. # @see WaitHelper # @see ElementExtensions 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 # Wait while the block evaluates to true or times out. # # @example # Watir::Wait.while(5) { browser.text_field.exists? } # # @param [Fixnum] timeout timeout to wait while block returns true. # @yieldparam [self] instance instance of self. # @raise [TimeoutError] when timeout exceeds. # @see WaitHelper # @see ElementExtensions 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 end # Wait end # Watir
Version data entries
9 entries across 9 versions & 1 rubygems