"unable to connect to chromedriver" error

I’ve just updated our rails/rspec project to chromedriver (it used to be capybara-webkit).

It’s all connecting and executing ok locally but when I put it onto Circle, the machine isn’t managing to find the chromedriver:

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

Circle config

The pertinent details of my circle config file are below:

#...
steps:
 - checkout
 - restore_cache: # Restore bundle cache
     keys:
       - v2-dependencies-{{ checksum "Gemfile.lock" }}
       - v2-dependencies-
 - browser-tools/install-browser-tools
#....
 - run:
     name: run tests
     command: bundle exec rspec --drb --colour --format documentation --order rand --format RspecJunitFormatter --out /tmp/circleci-test-results/rspec.xml $TEST_FILES

Verifying that chromedriver is installed…

If I SSH into the box I can verify that both Chrome and chromedriver are present but for some reason I can’t connect to them in the tests:

$ chromedriver --version
# => ChromeDriver 73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72)

$ google-chrome --version
# => Google Chrome 73.0.3683.103 

I’m sure there’s something simple I’m missing but what it is is a mystery…

You could try waiting for a bit (sleep or using listener detection) before running the tests - maybe the Chromedriver listener takes a while to start up?