How to enable Chromedriver logging
When using Chrome for Selenium tests, the chromedriver
binary will be used to control Chrome. To debug problems that stem from Selenium's Chrome and/or Chromedriver, you might want to enable logging for the chromedriver itself. Here is how.
Option 1: Use Selenium::WebDriver::Service
In your test setup, you may already have something like Capybara::Selenium::Driver.new(@app, browser: :chrome, options: ...)
, especially when passing options like device emulation.
Similar to options
, simply add an extra key service
and pass an instance of Selenium::WebDriver::Service
like so:
Copyservice = ::Selenium::WebDriver::Service.chrome(args: { verbose: true, log_path: '/tmp/chromedriver.log' }) ::Capybara::Selenium::Driver.new(@app, browser: :chrome, options: ..., service: service)
Note that version 3.x also supports passing the service arguments as driver_opts
directly. However, this is deprecated and will be removed in version 4 of selenium-webdriver.
Option 2: Connect tests to a manually started chromedriver
If the above approach no longer works, or if you want to go bare metal, you can also start chromedriver yourself in a terminal on a custom port:
Copychromedriver --port=12345 --verbose --log-path=/tmp/chromedriver.log
Then configure Selenium to connect to that port. Like in option 1, you need to pass an extra key when creating your driver instance.
CopyCapybara::Selenium::Driver.new(@app, browser: :chrome, options: ..., url: 'http://localhost:12345')
Note that you may omit the --log-path
option to make chromedriver print to your terminal.
Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for unsupported versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2).