Allow new errors returned by selenium-webdriver 3.4.x

This commit is contained in:
Thomas Walpole 2017-04-21 20:31:28 -07:00
parent 14d9f2afc8
commit 084cf8eded
1 changed files with 13 additions and 4 deletions

View File

@ -35,6 +35,13 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
def initialize(app, options={}) def initialize(app, options={})
begin begin
require 'selenium-webdriver' require 'selenium-webdriver'
# Fix for selenium-webdriver 3.4.0 which misnamed these
if !defined?(::Selenium::WebDriver::Error::ElementNotInteractableError)
::Selenium::WebDriver::Error.const_set('ElementNotInteractableError', Class.new(::Selenium::WebDriver::Error::WebDriverError))
end
if !defined?(::Selenium::WebDriver::Error::ElementClickInterceptedError)
::Selenium::WebDriver::Error.const_set('ElementClickInterceptedError', Class.new(::Selenium::WebDriver::Error::WebDriverError))
end
rescue LoadError => e rescue LoadError => e
if e.message =~ /selenium-webdriver/ if e.message =~ /selenium-webdriver/
raise LoadError, "Capybara's selenium driver is unable to load `selenium-webdriver`, please install the gem and add `gem 'selenium-webdriver'` to your Gemfile if you are using bundler." raise LoadError, "Capybara's selenium driver is unable to load `selenium-webdriver`, please install the gem and add `gem 'selenium-webdriver'` to your Gemfile if you are using bundler."
@ -250,10 +257,12 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
end end
def invalid_element_errors def invalid_element_errors
[Selenium::WebDriver::Error::StaleElementReferenceError, [::Selenium::WebDriver::Error::StaleElementReferenceError,
Selenium::WebDriver::Error::UnhandledError, ::Selenium::WebDriver::Error::UnhandledError,
Selenium::WebDriver::Error::ElementNotVisibleError, ::Selenium::WebDriver::Error::ElementNotVisibleError,
Selenium::WebDriver::Error::InvalidSelectorError] # Work around a race condition that can occur with chromedriver and #go_back/#go_forward ::Selenium::WebDriver::Error::InvalidSelectorError, # Work around a race condition that can occur with chromedriver and #go_back/#go_forward
::Selenium::WebDriver::Error::ElementNotInteractableError,
::Selenium::WebDriver::Error::ElementClickInterceptedError]
end end
def no_such_window_error def no_such_window_error