Last active
March 4, 2017 16:53
-
-
Save iloveitaly/d7e88e3a596caf2cfb690944d5fcd228 to your computer and use it in GitHub Desktop.
Setup Capybara to Use Chrome and Enable Verbose Logging
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
# https://groups.google.com/forum/#!topic/ruby-capybara/G6d3HHgvWCE | |
# https://github.com/teamcapybara/capybara/issues/1305 | |
# http://www.assertselenium.com/java/list-of-chrome-driver-command-line-arguments/ | |
Capybara.register_driver :selenium_chrome_driver do |app| | |
client = Selenium::WebDriver::Remote::Http::Default.new | |
# recent capybara versions have these two separate properties | |
client.open_timeout = 60 * 5 | |
client.read_timeout = 60 * 5 | |
# https://github.com/teamcapybara/capybara/blob/master/lib/capybara/selenium/driver.rb | |
Capybara::Selenium::Driver.new(app, | |
# NOTE this entire hash (excluding some "special" params) are passed off to the bridge | |
# https://github.com/SeleniumHQ/selenium/blob/6e5fe5a5d93a66bfef3288b5da4bc553fa384bba/rb/lib/selenium/webdriver/chrome/bridge.rb#L26 | |
browser: :chrome, | |
http_client: client, | |
desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome( | |
# in edge selenium there's a new `driver_opts` which may replace some of the server args | |
# https://github.com/SeleniumHQ/selenium/blob/6e5fe5a5d93a66bfef3288b5da4bc553fa384bba/rb/lib/selenium/webdriver/chrome/bridge.rb#L32 | |
driver_opts: { | |
log_path: "/Users/Mike/Projects/stripe-netsuite/log/capybara.log" | |
}, | |
'chromeOptions' => { | |
'args' => %w(--flag) | |
}, | |
), | |
# the current method of setting logging parameters | |
# https://github.com/SeleniumHQ/selenium/blob/2cd8007f8d694ffc278296aa896d6f01a676cd0c/rb/lib/selenium/webdriver/chrome/bridge.rb#L97 | |
service_args: { | |
service_log_path: "/Users/Mike/Projects/stripe-netsuite/log/capybara.log", | |
verbose: true, | |
silent: false | |
}, | |
# `:args` or `:switches` can also be used, but these options are overwritten by `service_args` | |
# https://github.com/SeleniumHQ/selenium/blob/2cd8007f8d694ffc278296aa896d6f01a676cd0c/rb/lib/selenium/webdriver/chrome/bridge.rb#L73 | |
switches: %w(--verbose --log-path="/Users/Mike/Projects/stripe-netsuite/log/capybara.log"), | |
) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment