Getting Headless Chrome to work with Capybara

Viewed 1274

Im a bit stuck, im following thoughtbots tutorial on this and everything "looks" correct: https://robots.thoughtbot.com/headless-feature-specs-with-chrome

  • I've verified my Chrome is version 59
  • I've used brew to install chromedriver, and verified it's version 2.3 at least

my rails_helper file (the relevant part) looks like this:

Capybara.register_driver :chrome do |app|
  Capybara::Selenium::Driver.new(app, browser: :chrome)
end

Capybara.register_driver :headless_chrome do |app|
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
    'chromeOptions:' => { args: %w(headless disable-gpu) }
  )

  Capybara::Selenium::Driver.new app,
    browser: :chrome,
    desired_capabilities: capabilities
end

Capybara.javascript_driver = :headless_chrome

Using the chromedriver-helper gem does allow me to use chrome just fine, but it doesn't stay headless. Also when I would check it I would confirm on the chrome that the automation test uses that no --headless flag appears.

What it's giving me now using the brew install chromedriver is:

Selenium::WebDriver::Error::WebDriverError:
       unable to connect to chromedriver 127.0.0.1:9515

So something seems off....it doesn't seem to know how to connect the brew chromedriver version..however most tutorials don't seem to say anything about linking anything using the brew version.

Any ideas? (Im Running on Rails 4.1 btw)

1 Answers
Related