diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8514686..a145945 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -28,7 +28,6 @@ end else require "selenium/webdriver" - require_relative "support/selenium_error_patch" options = Selenium::WebDriver::Chrome::Options.new options.add_preference(:download, prompt_for_download: false, @@ -36,6 +35,8 @@ options.add_preference(:browser, set_download_behavior: { behavior: "allow" }) + options.add_argument("--disable-features=DeferRendererTasksAfterInput") + Capybara.register_driver :chrome do |app| Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) end diff --git a/spec/support/selenium_error_patch.rb b/spec/support/selenium_error_patch.rb deleted file mode 100644 index 57f8c07..0000000 --- a/spec/support/selenium_error_patch.rb +++ /dev/null @@ -1,34 +0,0 @@ -# Monkey patch for a specific intermittent Selenium error. -# -# Intermittently, Selenium/Chromedriver raises `Selenium::WebDriver::Error::UnknownError` -# with the message "Node with given id does not belong to the document". - -# Capybara's automatic waiting/retrying mechanism doesn't catch it, -# leading to failure. -# -# We intercept the initialization of `UnknownError`. If the message matches this specific -# case, we raise a `StaleElementReferenceError` instead. This uses Capybara's -# retry logic which makes doesn't fail the test -# -# This can be removed once the following issue is resolved: -# https://github.com/teamcapybara/capybara/issues/2800 -# -# taken from the following issue: -# https://github.com/teamcapybara/capybara/issues/2800#issuecomment-3049956982 - -module Selenium - module WebDriver - module Error - class UnknownError - alias_method :old_initialize, :initialize - def initialize(msg = nil) - if msg&.include?("Node with given id does not belong to the document") - raise StaleElementReferenceError, msg - end - - old_initialize(msg) - end - end - end - end -end