Skip to content

Commit

Permalink
Merge pull request #8 from willnet/ferrum
Browse files Browse the repository at this point in the history
Add Ferrum Support
  • Loading branch information
willnet committed May 19, 2023
2 parents e97c361 + c74f6aa commit 2cddf89
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/capybara/wait_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
module Capybara
# Wait for image to load automatically
module WaitImage
def _stale_errors
return @_stale_errors if defined? @_stale_errors

@_stale_errors = []
if defined? ::Selenium::WebDriver::Error::StaleElementReferenceError
@_stale_errors << ::Selenium::WebDriver::Error::StaleElementReferenceError
end
@_stale_errors << ::Ferrum::NodeNotFoundError if defined? ::Ferrum::NodeNotFoundError
@_stale_errors
end

def _wait_for_image_loading # rubocop:disable Metrics/MethodLength
Timeout.timeout(Capybara.default_max_wait_time) do
sleep 0.5 until evaluate_script(<<~JS)
Expand All @@ -19,8 +30,8 @@ def _wait_for_image_loading # rubocop:disable Metrics/MethodLength
_logger.debug "[capybara-wait_image]Timeout::Error"
rescue Capybara::NotSupportedByDriverError
# It comes here when you run it in rack-test, but you can ignore it
rescue ::Selenium::WebDriver::Error::StaleElementReferenceError
_logger.debug "[capybara-wait_image]Selenium::WebDriver::Error::StaleElementReferenceError"
rescue *_stale_errors
_logger.debug "[capybara-wait_image]Stale Error"
reload
_wait_for_image_loading
end
Expand Down

0 comments on commit 2cddf89

Please sign in to comment.