Update standard rescued variable names
This commit is contained in:
parent
c8d48d41ba
commit
0873c9052d
|
@ -300,7 +300,7 @@ module Capybara
|
||||||
synchronize(Capybara::Queries::BaseQuery.wait(options, session_options.default_max_wait_time)) do
|
synchronize(Capybara::Queries::BaseQuery.wait(options, session_options.default_max_wait_time)) do
|
||||||
begin
|
begin
|
||||||
find(:select, from, options)
|
find(:select, from, options)
|
||||||
rescue Capybara::ElementNotFound => select_error
|
rescue Capybara::ElementNotFound => select_error # rubocop:disable Naming/RescuedExceptionsVariableName
|
||||||
raise if %i[selected with_selected multiple].any? { |option| options.key?(option) }
|
raise if %i[selected with_selected multiple].any? { |option| options.key?(option) }
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
@ -356,14 +356,14 @@ module Capybara
|
||||||
begin
|
begin
|
||||||
el = find(selector, locator, options)
|
el = find(selector, locator, options)
|
||||||
el.set(checked)
|
el.set(checked)
|
||||||
rescue StandardError => err
|
rescue StandardError => e
|
||||||
raise unless allow_label_click && catch_error?(err)
|
raise unless allow_label_click && catch_error?(e)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
el ||= find(selector, locator, options.merge(visible: :all))
|
el ||= find(selector, locator, options.merge(visible: :all))
|
||||||
el.session.find(:label, for: el, visible: true).click unless el.checked? == checked
|
el.session.find(:label, for: el, visible: true).click unless el.checked? == checked
|
||||||
rescue StandardError # swallow extra errors - raise original
|
rescue StandardError # swallow extra errors - raise original
|
||||||
raise err
|
raise e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -81,19 +81,19 @@ module Capybara
|
||||||
timer = Capybara::Helpers.timer(expire_in: seconds)
|
timer = Capybara::Helpers.timer(expire_in: seconds)
|
||||||
begin
|
begin
|
||||||
yield
|
yield
|
||||||
rescue StandardError => err
|
rescue StandardError => e
|
||||||
session.raise_server_error!
|
session.raise_server_error!
|
||||||
raise err unless catch_error?(err, errors)
|
raise e unless catch_error?(e, errors)
|
||||||
|
|
||||||
if driver.wait?
|
if driver.wait?
|
||||||
raise err if timer.expired?
|
raise e if timer.expired?
|
||||||
|
|
||||||
sleep(0.01)
|
sleep(0.01)
|
||||||
reload if session_options.automatic_reload
|
reload if session_options.automatic_reload
|
||||||
else
|
else
|
||||||
old_base = @base
|
old_base = @base
|
||||||
reload if session_options.automatic_reload
|
reload if session_options.automatic_reload
|
||||||
raise err if old_base == @base
|
raise e if old_base == @base
|
||||||
end
|
end
|
||||||
retry
|
retry
|
||||||
ensure
|
ensure
|
||||||
|
|
|
@ -87,11 +87,11 @@ module Capybara
|
||||||
|
|
||||||
begin
|
begin
|
||||||
synchronize { base.style(styles) }
|
synchronize { base.style(styles) }
|
||||||
rescue NotImplementedError => err
|
rescue NotImplementedError => e
|
||||||
begin
|
begin
|
||||||
evaluate_script(STYLE_SCRIPT, *styles)
|
evaluate_script(STYLE_SCRIPT, *styles)
|
||||||
rescue Capybara::NotSupportedByDriverError
|
rescue Capybara::NotSupportedByDriverError
|
||||||
raise err
|
raise e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -469,8 +469,8 @@ module Capybara
|
||||||
begin
|
begin
|
||||||
reloaded = query_scope.reload.first(@query.name, @query.locator, @query.options)
|
reloaded = query_scope.reload.first(@query.name, @query.locator, @query.options)
|
||||||
@base = reloaded.base if reloaded
|
@base = reloaded.base if reloaded
|
||||||
rescue StandardError => err
|
rescue StandardError => e
|
||||||
raise err unless catch_error?(err)
|
raise e unless catch_error?(e)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self
|
self
|
||||||
|
|
|
@ -83,7 +83,7 @@ module Capybara
|
||||||
matches_system_filters?(node) &&
|
matches_system_filters?(node) &&
|
||||||
matches_node_filters?(node, node_filter_errors) &&
|
matches_node_filters?(node, node_filter_errors) &&
|
||||||
matches_filter_block?(node)
|
matches_filter_block?(node)
|
||||||
rescue *(node.respond_to?(:session) ? node.session.driver.invalid_element_errors : [])
|
rescue *(node.respond_to?(:session) ? node.session.driver.invalid_element_errors : []) # rubocop:disable Naming/RescuedExceptionsVariableName
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,8 @@ module Capybara
|
||||||
class WrappedElementMatcher < Base
|
class WrappedElementMatcher < Base
|
||||||
def matches?(actual)
|
def matches?(actual)
|
||||||
element_matches?(wrap(actual))
|
element_matches?(wrap(actual))
|
||||||
rescue Capybara::ExpectationNotMet => err
|
rescue Capybara::ExpectationNotMet => e
|
||||||
@failure_message = err.message
|
@failure_message = e.message
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
|
||||||
def self.load_selenium
|
def self.load_selenium
|
||||||
require 'selenium-webdriver'
|
require 'selenium-webdriver'
|
||||||
warn "Warning: You're using an unsupported version of selenium-webdriver, please upgrade." if Gem.loaded_specs['selenium-webdriver'].version < Gem::Version.new('3.5.0')
|
warn "Warning: You're using an unsupported version of selenium-webdriver, please upgrade." if Gem.loaded_specs['selenium-webdriver'].version < Gem::Version.new('3.5.0')
|
||||||
rescue LoadError => err
|
rescue LoadError => e
|
||||||
raise err if err.message !~ /selenium-webdriver/
|
raise e unless e.message.match?(/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."
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,8 +7,8 @@ module Capybara::Selenium::Driver::ChromeDriver
|
||||||
within_given_window(handle) do
|
within_given_window(handle) do
|
||||||
begin
|
begin
|
||||||
super
|
super
|
||||||
rescue NoMethodError => err
|
rescue NoMethodError => e
|
||||||
raise unless err.message =~ /full_screen_window/
|
raise unless e.message =~ /full_screen_window/
|
||||||
|
|
||||||
result = bridge.http.call(:post, "session/#{bridge.session_id}/window/fullscreen", {})
|
result = bridge.http.call(:post, "session/#{bridge.session_id}/window/fullscreen", {})
|
||||||
result['value']
|
result['value']
|
||||||
|
|
|
@ -97,13 +97,13 @@ class Capybara::Selenium::Node < Capybara::Driver::Node
|
||||||
return native.click if click_options.empty?
|
return native.click if click_options.empty?
|
||||||
|
|
||||||
click_with_options(click_options)
|
click_with_options(click_options)
|
||||||
rescue StandardError => err
|
rescue StandardError => e
|
||||||
if err.is_a?(::Selenium::WebDriver::Error::ElementClickInterceptedError) ||
|
if e.is_a?(::Selenium::WebDriver::Error::ElementClickInterceptedError) ||
|
||||||
err.message =~ /Other element would receive the click/
|
e.message.match?(/Other element would receive the click/)
|
||||||
scroll_to_center
|
scroll_to_center
|
||||||
end
|
end
|
||||||
|
|
||||||
raise err
|
raise e
|
||||||
end
|
end
|
||||||
|
|
||||||
def right_click(keys = [], **options)
|
def right_click(keys = [], **options)
|
||||||
|
|
|
@ -14,8 +14,8 @@ class Capybara::Selenium::ChromeNode < Capybara::Selenium::Node
|
||||||
|
|
||||||
def set_file(value) # rubocop:disable Naming/AccessorMethodName
|
def set_file(value) # rubocop:disable Naming/AccessorMethodName
|
||||||
super(value)
|
super(value)
|
||||||
rescue ::Selenium::WebDriver::Error::ExpectedError => err
|
rescue ::Selenium::WebDriver::Error::ExpectedError => e
|
||||||
raise ArgumentError, "Selenium < 3.14 with remote Chrome doesn't support multiple file upload" if err.message.match?(/File not found : .+\n.+/m)
|
raise ArgumentError, "Selenium < 3.14 with remote Chrome doesn't support multiple file upload" if e.message.match?(/File not found : .+\n.+/m)
|
||||||
|
|
||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,7 +12,7 @@ module Capybara
|
||||||
|
|
||||||
def request(&block)
|
def request(&block)
|
||||||
ssl? ? https_request(&block) : http_request(&block)
|
ssl? ? https_request(&block) : http_request(&block)
|
||||||
rescue *TRY_HTTPS_ERRORS
|
rescue *TRY_HTTPS_ERRORS # rubocop:disable Naming/RescuedExceptionsVariableName
|
||||||
res = https_request(&block)
|
res = https_request(&block)
|
||||||
@ssl = true
|
@ssl = true
|
||||||
res
|
res
|
||||||
|
|
|
@ -46,9 +46,9 @@ module Capybara
|
||||||
@counter.increment
|
@counter.increment
|
||||||
begin
|
begin
|
||||||
@extended_app.call(env)
|
@extended_app.call(env)
|
||||||
rescue *@server_errors => err
|
rescue *@server_errors => e
|
||||||
@error ||= err
|
@error ||= e
|
||||||
raise err
|
raise e
|
||||||
ensure
|
ensure
|
||||||
@counter.decrement
|
@counter.decrement
|
||||||
end
|
end
|
||||||
|
|
|
@ -49,7 +49,7 @@ module Capybara
|
||||||
# @return [Boolean] whether this window is the window in which commands are being executed
|
# @return [Boolean] whether this window is the window in which commands are being executed
|
||||||
def current?
|
def current?
|
||||||
@driver.current_window_handle == @handle
|
@driver.current_window_handle == @handle
|
||||||
rescue @driver.no_such_window_error
|
rescue @driver.no_such_window_error # rubocop:disable Naming/RescuedExceptionsVariableName
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue