Chromedriver error in Selenium rails tests

Viewed 1389

Attempting to run rspec tests written by some other developers. But the tests are failing with the following error

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

  0) /media/uploader product video wistia uploads adds video when links is valid
     Failure/Error: visit login_path

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

The gemfile does not contain the chromedriver-helper gem but that shouldn't be a problem, as other developers have been able to run the tests successfully without the gem in the gemfile. I've tried brew installing chromedriver but that hasn't helped. I suspect the issue has something to do with the fact that the repo is using ruby 2.2.8, but chromedriver, for some reason, is only available with 2.4.2.

asahmed:~/Documents/workspace/vendor-portal-next (master) $ chromedriver -v
rbenv: chromedriver: command not found

The `chromedriver' command exists in these Ruby versions:
  2.4.2

Can anyone help me with this?

2 Answers

I have had a similar issue, it was a result of being unable to get rid of the rbenv chromedriver shim. Following the steps in this comment fixed it for me.

In my case the gemfile did contain chromedriver-helper, but in case it is the same issue I thought I would comment.

https://github.com/flavorjones/chromedriver-helper/issues/44#issuecomment-358743719

The steps are:

First check if

❯ which chromedriver

returns

/Users/xxx/.rbenv/shims/chromedriver

if so try

❯ ls ~/.rbenv/versions/*/bin/* | grep chromedriver

to get the list of chromedriver executables on disc.

Then remove those executables with

❯ rm [path to chromedriver and chromedriver-update executables]

Finally run

❯ rbenv rehash

You have an old version of the chromedriver-helper gem installed (in Ruby 2.4.2), which supplies a chromedriver executable -- that is appearing in your PATH before your "real" chromedriver installed by brew.

To solve the problem, you can either:

  • uninstall the gem causing the problem: rbenv shell 2.4.2; gem uninstall chromedriver-helper -- this will fix it for now, but it might come back if it's mentioned by some other project's Gemfile
  • install an old version of chromedriver-helper in your running ruby: gem install chromedriver-helper -v 1.2.0
  • somehow convince the brew-supplied executable to be preferred over the rbenv one

I'd recommend going for option 1, and chasing down any other projects and bumping their chromedriver-helper to 2.0+.

Related