Class: ToleranceForSeleniumSyncIssues::Patiently

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

Constant Summary collapse

WAIT_PERIOD =
0.05

Instance Method Summary collapse

Instance Method Details

#patiently(seconds, &block) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/Ifd_Automation/tolerance_for_selenium_sync_issues.rb', line 40

def patiently(seconds, &block)
  started = Time.now
  tries = 0
  begin
    tries += 1
    block.call
  rescue Exception => e
    raise e unless retryable_error?(e)
    raise e if (Time.now - 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 Time.now == started
    retry
  end
end