Module: PageMagic::WaitMethods

Included in:
Element, InstanceMethods
Defined in:
lib/page_magic/wait_methods.rb

Overview

module WaitMethods - contains methods for waiting

Instance Method Summary collapse

Instance Method Details

#wait_until(timeout_after: 5, retry_every: 1, &_block) ⇒ Object

Wait until a the supplied block returns true

Examples:

wait_until do
  (rand % 2) == 0
end

Raises:



9
10
11
12
13
14
15
16
# File 'lib/page_magic/wait_methods.rb', line 9

def wait_until(timeout_after: 5, retry_every: 1, &_block)
  start_time = Time.now
  until Time.now > start_time + timeout_after
    return true if yield == true
    sleep retry_every
  end
  raise TimeoutException, 'Action took to long'
end