-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- use new Capybara::Selenium::Driver options - allow firefox and firefox headless as well - default to firefox_headless
- Loading branch information
1 parent
368fb10
commit 805523c
Showing
2 changed files
with
26 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,31 @@ | ||
require "webdrivers" | ||
|
||
def register_driver(name, args = [], opts = {}) | ||
def register_driver(browser, name, args, headless: false) | ||
case browser | ||
when :firefox | ||
options = Selenium::WebDriver::Firefox::Options.new | ||
when :chrome | ||
options = Selenium::WebDriver::Chrome::Options.new | ||
else | ||
raise "what browser?" | ||
end | ||
|
||
Capybara.register_driver(name) do |app| | ||
options = { args: args + ["window-size=1440,1080"] } | ||
options[:binary] = ENV.fetch("GOOGLE_CHROME_SHIM", nil) | ||
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(chromeOptions: options.compact) | ||
Capybara::Selenium::Driver.new(app, { browser: :chrome, desired_capabilities: capabilities }.merge(opts)) | ||
args.each { |arg| options.add_argument arg } | ||
options.headless! if headless | ||
Capybara::Selenium::Driver.new(app, browser: browser, options: options) | ||
end | ||
end | ||
|
||
register_driver(:chrome) | ||
register_driver(:chrome_headless, %w[headless disable-gpu no-sandbox disable-dev-shm-usage]) | ||
driver_arguments = %w[ | ||
disable-impl-side-painting | ||
window-size=1440,1080 | ||
no-sandbox | ||
disable-gpu | ||
disable-dev-shm-usage | ||
verbose | ||
] | ||
register_driver(:chrome, :chrome, driver_arguments) | ||
register_driver(:chrome, :chrome_headless, driver_arguments, headless: true) | ||
register_driver(:firefox, :firefox, driver_arguments) | ||
register_driver(:firefox, :firefox_headless, driver_arguments, headless: true) |