Module: Thoran::Selenium::WebDriver::Driver::Attempt
- Included in:
- Selenium::WebDriver::Driver
- Defined in:
- lib/Thoran/Selenium/WebDriver/Driver/Attempt/attempt.rb
Constant Summary collapse
- TRANSIENT_ERRORS =
[ ::Selenium::WebDriver::Error::ElementClickInterceptedError, ::Selenium::WebDriver::Error::ElementNotInteractableError, ::Selenium::WebDriver::Error::NoSuchElementError, ::Selenium::WebDriver::Error::StaleElementReferenceError, ::Selenium::WebDriver::Error::TimeoutError, ::Selenium::WebDriver::Error::UnexpectedAlertOpenError, ::Selenium::WebDriver::Error::UnknownError, ].freeze
Instance Method Summary collapse
Instance Method Details
#attempt(max_attempts = 3) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/Thoran/Selenium/WebDriver/Driver/Attempt/attempt.rb', line 40 def attempt(max_attempts = 3) attempts = 0 begin yield self rescue *TRANSIENT_ERRORS => e attempts += 1 warn "Attempt #{attempts} of #{max_attempts} failed: #{e.class}" retry if attempts < max_attempts raise end end |