rspec & rvm: unable to connect to chromedriver 127.0.0.1:9515 due to conflicting chromedrivers

After updating mac to Mojave, I ran into problems with Ruby 2.5.1 and had to reinstall it (I use rvm for that) and re-bundle my automation project.
It looks like rvm symlinks chromedriver to its own location:

$ which chromedriver
/Users/anks/.rvm/gems/ruby-2.5.1/bin/chromedriver

However, when I run my automation suite, I get:

Failure/Error: raise Error::WebDriverError, cannot_connect_error_text
Selenium::WebDriver::Error::WebDriverError:
unable to connect to chromedriver 127.0.0.1:9515

and the browser doesn’t start.

I don’t know for sure, but after reading this thread on Github I figured that 2 chromedrivers (one in local and one in rvm) don’t work with each other very well.
Thanks to the thread above, I managed to fix this and since I had to use this solution at least twice now, I’m putting it here for future reference.

curl https://chromedriver.storage.googleapis.com/73.0.3683.68/chromedriver_mac64.zip -o chromedriver_mac64.zip
unzip chromedriver_mac64.zip
mv chromedriver /usr/local/bin
chmod +x /usr/local/bin/chromedriver
rm chromedriver_mac64.zip

Now, which chromedriver still returns the rvm location. To fix this, remove the chromedriver directory:

rm -rf /Users/anks/.rvm/gems/ruby-2.5.1/bin/chromedriver

and now which chromedriver is properly linked to local version:

$ which chromedriver
/usr/local/bin/chromedriver

Written By anks

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.