4

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)

27
  • I would look into using poltergeist with phantomjs and capybara. It is fully headless & handles js great. Commented Jul 12, 2017 at 19:24
  • @bkunzi01 Thats what I used before, however I wanted to at least give headless chrome a try. Commented Jul 12, 2017 at 19:31
  • do bundle exec chromedriver -v and tell us what it prints, also - comment out the :chrome driver registration so you only have :headless_chrome - that will make sure you're not setting the driver to :chrome somewhere else Commented Jul 12, 2017 at 19:49
  • @bkunzi01 Unfortunately, phantomjs currently has the downside of not supporting anything beyond ES5 or newer CSS (grids, etc)- which means a lot of newer stuff requires polyfilling and transpiling every piece of JS in the app - headless chrome makes things a lot cleaner from a testing perspective Commented Jul 12, 2017 at 19:52
  • 1
    Your chromedriver should be version >= 2.30 not >= 2.3 Commented Jul 13, 2017 at 8:22

1 Answer 1

5

Since you're using brew to install chromedriver you need to completely remove chromedriver-helper and all the binaries and stubs it has installed. This is because bundler adds the installed binaries/stubs into the path before the version of chromedriver installed by brew and therefore shadows it. You can use

bundle exec which chromedriver 

to find out which chromedriver is actually being used when you run your tests. If it's not the one installed by brew (usually /usr/local/bin/chromedriver) then keep removing them until it is.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.