module Thoran::Selenium::WebDriver::Driver::Attempt
Public Instance Methods
attempt(max_attempts = 3) { || ... }
click to toggle source
# File lib/Thoran/Selenium/WebDriver/Driver/Attempt/attempt.rb, line 24 def attempt(max_attempts = 3, &block) attempts = 0 loop do begin yield break rescue Timeout::Error, ::Selenium::WebDriver::Error::UnknownError, ::Selenium::WebDriver::Error::NoSuchElementError => e attempts += 1 if attempts >= max_attempts @driver.quit puts "Giving up after #{max_attempts} attempts to #{__method__} because #{e}." exit end end end end