Class: ToleranceForSeleniumSyncIssues::Patiently

Inherits:
Object
  • Object
show all
Defined in:
lib/spreewald_support/tolerance_for_selenium_sync_issues.rb

Constant Summary collapse

WAIT_PERIOD =
0.05

Instance Method Summary collapse

Instance Method Details

#patiently(seconds, &block) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/spreewald_support/tolerance_for_selenium_sync_issues.rb', line 25

def patiently(seconds, &block)
  patiently_started = monotonic_time
  tries = 0
  begin
    tries += 1
    block_started = monotonic_time
    block.call
  rescue Exception => e
    raise e unless retryable_error?(e)
    raise e if (block_started - patiently_started > seconds && tries >= 2)
    sleep(WAIT_PERIOD)
    raise Capybara::FrozenInTime, "time appears to be frozen, Capybara does not work with libraries which freeze time, consider using time travelling instead" if monotonic_time == patiently_started
    retry
  end
end