module Turnip::ExtraSteps::Support::ToleranceForSeleniumSyncIssues
Constants
- RETRY_ERRORS
Public Instance Methods
patiently(seconds=Capybara.default_wait_time, &block)
click to toggle source
This is similiar but not entirely the same as Capybara::Node::Base#wait_until or Capybara::Session#wait_until
# File lib/turnip/extra_steps/support/tolerance_for_selenium_sync_issues.rb, line 19 def patiently(seconds=Capybara.default_wait_time, &block) old_wait_time = Capybara.default_wait_time # dont make nested wait_untils use up all the alloted time Capybara.default_wait_time = 0 # for we are a jealous gem if page.driver.wait? start_time = Time.now begin block.call rescue Exception => e raise e unless RETRY_ERRORS.include?(e.class.name) raise e if (Time.now - start_time) >= seconds sleep(0.05) 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 == start_time retry end else block.call end ensure Capybara.default_wait_time = old_wait_time end