1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
# frozen_string_literal: true
module Capybara
module Selenium
module DeprecationSuppressor
def initialize(*)
@suppress_for_capybara = false
super
end
def deprecate(*args, **opts, &block)
return if @suppress_for_capybara
if opts.empty?
super(*args, &block) # support Selenium 3
else
super
end
end
def suppress_deprecations
prev_suppress_for_capybara, @suppress_for_capybara = @suppress_for_capybara, true
yield
ensure
@suppress_for_capybara = prev_suppress_for_capybara
end
end
module ErrorSuppressor
def for_code(*)
::Selenium::WebDriver.logger.suppress_deprecations do
super
end
end
end
end
end
Selenium::WebDriver::Logger.prepend Capybara::Selenium::DeprecationSuppressor
Selenium::WebDriver::Error.singleton_class.prepend Capybara::Selenium::ErrorSuppressor
|