diff --git a/.rubocop.yml b/.rubocop.yml index def0539c..9edc76e8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -62,6 +62,12 @@ Lint/UnusedMethodArgument: - 'lib/capybara/driver/base.rb' - 'lib/capybara/driver/node.rb' +Lint/RaiseException: + Enabled: true + +Lint/StructNewOverride: + Enabled: true + Layout/EndAlignment: EnforcedStyleAlignWith: variable diff --git a/lib/capybara/selenium/driver.rb b/lib/capybara/selenium/driver.rb index aa361ce6..9acb60e9 100644 --- a/lib/capybara/selenium/driver.rb +++ b/lib/capybara/selenium/driver.rb @@ -241,7 +241,7 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base def quit @browser&.quit - rescue Selenium::WebDriver::Error::SessionNotCreatedError, Errno::ECONNREFUSED # rubocop:disable Lint/SuppressedException + rescue Selenium::WebDriver::Error::SessionNotCreatedError, Errno::ECONNREFUSED # Browser must have already gone rescue Selenium::WebDriver::Error::UnknownError => e unless silenced_unknown_error_message?(e.message) # Most likely already gone @@ -293,7 +293,7 @@ private def clear_browser_state delete_all_cookies clear_storage - rescue *clear_browser_state_errors # rubocop:disable Lint/SuppressedException + rescue *clear_browser_state_errors # delete_all_cookies fails when we've previously gone # to about:blank, so we rescue this error and do nothing # instead. @@ -317,7 +317,7 @@ private def clear_storage clear_session_storage unless options[:clear_session_storage] == false clear_local_storage unless options[:clear_local_storage] == false - rescue Selenium::WebDriver::Error::JavascriptError # rubocop:disable Lint/SuppressedException + rescue Selenium::WebDriver::Error::JavascriptError # session/local storage may not be available if on non-http pages (e.g. about:blank) end @@ -353,7 +353,7 @@ private @browser.navigate.to(url) sleep 0.1 # slight wait for alert @browser.switch_to.alert.accept - rescue modal_error # rubocop:disable Lint/SuppressedException + rescue modal_error # alert now gone, should mean navigation happened end diff --git a/lib/capybara/selenium/driver_specializations/firefox_driver.rb b/lib/capybara/selenium/driver_specializations/firefox_driver.rb index c478858c..6c291626 100644 --- a/lib/capybara/selenium/driver_specializations/firefox_driver.rb +++ b/lib/capybara/selenium/driver_specializations/firefox_driver.rb @@ -46,7 +46,7 @@ module Capybara::Selenium::Driver::W3CFirefoxDriver begin # Firefox 68 hangs if we try to switch windows while a modal is visible browser.switch_to.alert&.dismiss - rescue Selenium::WebDriver::Error::NoSuchAlertError # rubocop:disable Lint/SuppressedException + rescue Selenium::WebDriver::Error::NoSuchAlertError # Swallow end end @@ -61,7 +61,7 @@ module Capybara::Selenium::Driver::W3CFirefoxDriver accept_modal :confirm, wait: 0.1 do super end - rescue Capybara::ModalNotFound # rubocop:disable Lint/SuppressedException + rescue Capybara::ModalNotFound # No modal was opened - page has refreshed - ignore end diff --git a/lib/capybara/selenium/node.rb b/lib/capybara/selenium/node.rb index 12f0fb75..a7a0c816 100644 --- a/lib/capybara/selenium/node.rb +++ b/lib/capybara/selenium/node.rb @@ -237,7 +237,7 @@ protected JS begin driver.execute_script(script, self) - rescue StandardError # rubocop:disable Lint/SuppressedException + rescue StandardError # Swallow error if scrollIntoView with options isn't supported end end