2

I'm using Cuprite driver for Capybara in my Ruby feature specs.

The specs run fine locally but fail with the error, Chrome process did not produce websocket url within 2 seconds, when the specs are run on our CI server. The CI server runs the specs within a Docker container.

The Docker image installs a recent version of Chrome, 77.0, from the Google PPA.

Kris
  • 19,188
  • 9
  • 91
  • 111

2 Answers2

6

The driver needs to be configured to pass the --no-sandbox option to Chrome:

Capybara.register_driver :cuprite do |app|
  browser_options = {}.tap do |opts|
    opts['no-sandbox'] = nil if ENV['CI']
  end

  Capybara::Cuprite::Driver.new(app, browser_options: browser_options)
end
Kris
  • 19,188
  • 9
  • 91
  • 111
0

I was just struggling with this issue on GitHub Actions. It turns out that the default process_timeout of 1 second is just too short, so Chrome didn't have time to start on the CI servers. It now works for me after extending process_timeout to a much larger value (20 seconds.) Here's the full code for my Capybara :cuprite driver:

  Capybara.register_driver(:cuprite) do |app|
    browser_options = {}
    browser_options['no-sandbox'] = nil if ENV['CI']
    headless = !ENV['SHOW_BROWSER']
    Capybara::Cuprite::Driver.new(
      app,
      browser_options: browser_options,
      headless: headless,
      process_timeout: 20
    )
  end
  Capybara.javascript_driver = :cuprite
ndbroadbent
  • 13,513
  • 3
  • 56
  • 85