Skip to content

Commit

Permalink
add_argument is available in all supported selenium-webdriver versions
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed Jan 20, 2021
1 parent 0ad261a commit 6440e5c
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions lib/capybara/registrations/drivers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
version = Capybara::Selenium::Driver.load_selenium
options_key = Capybara::Selenium::Driver::CAPS_VERSION.satisfied_by?(version) ? :capabilities : :options
browser_options = ::Selenium::WebDriver::Firefox::Options.new.tap do |opts|
if browser_options.respond_to?(:headless!)
opts.headless!
else
opts.args << '-headless'
end
opts.add_argument '-headless'
end
Capybara::Selenium::Driver.new(app, **Hash[:browser => :firefox, options_key => browser_options])
end
Expand All @@ -26,11 +22,7 @@
options_key = Capybara::Selenium::Driver::CAPS_VERSION.satisfied_by?(version) ? :capabilities : :options
browser_options = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts|
# Workaround https://bugs.chromium.org/p/chromedriver/issues/detail?id=2650&q=load&sort=-id&colspec=ID%20Status%20Pri%20Owner%20Summary
if opts.respond_to?(:add_argument)
opts.add_argument('--disable-site-isolation-trials')
else
opts.args << '--disable-site-isolation-trials'
end
opts.add_argument('--disable-site-isolation-trials')
end

Capybara::Selenium::Driver.new(app, **Hash[:browser => :firefox, options_key => browser_options])
Expand All @@ -40,14 +32,10 @@
version = Capybara::Selenium::Driver.load_selenium
options_key = Capybara::Selenium::Driver::CAPS_VERSION.satisfied_by?(version) ? :capabilities : :options
browser_options = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts|
if opts.respond_to?(:headless!)
opts.headless!
else
opts.args << '--headless'
end
opts.args << '--disable-gpu' if Gem.win_platform?
opts.add_argument('--headless')
opts.add_argument('--disable-gpu') if Gem.win_platform?
# Workaround https://bugs.chromium.org/p/chromedriver/issues/detail?id=2650&q=load&sort=-id&colspec=ID%20Status%20Pri%20Owner%20Summary
opts.args << '--disable-site-isolation-trials'
opts.add_argument('--disable-site-isolation-trials')
end

Capybara::Selenium::Driver.new(app, **Hash[:browser => :firefox, options_key => browser_options])
Expand Down

0 comments on commit 6440e5c

Please sign in to comment.