I use capybara & selenium test my rails project. when i execute the test script,it's has errors likes this
Selenium::WebDriver::Error::WebDriverError: Could not find Firefox binary (os=macosx). Make sure Firefox is installed or set the path manually with Selenium::WebDriver::Firefox::Binary.path= I google how to use Google Chrome as the testing browser instead of Firefox
but it occurs other errors likes
Selenium::WebDriver::Error::WebDriverError: unable to connect to chromedriver 310 Answers
I had the exact same issue. What worked for me was using the "webdrivers" gem. Part of my gemfile looks like this:
group :development, :test do gem 'rspec-rails' gem 'capybara' gem 'webdrivers' end 2On Mac OS
It works fine with watir-webdriver and Safari
browser = Watir::Browser.new :safari If you'd like to use Chrome, make sure that it is installed, plus you need to install mac os developer tools with
xcode-select --install and also install chromedriver with brew
brew install chromedriver On Linux
I had the same error on my staging Ubuntu 12.04 server and the problem was I didn't install chrome itself like this (with superuser permissions):
wget -q -O - | sudo apt-key add - sh -c 'echo "deb stable main" >> /etc/apt/sources.list.d/google.list' apt-get update apt-get install google-chrome-stable Install chromedriver(use proper path for your system and version):
wget unzip chromedriver_linux64.zip cp chromedriver /usr/local/bin chmod +x /usr/local/bin/chromedriver After that I would recommend you to use watir-webdriver in headless mode
require 'watir-webdriver' require 'headless' headless = Headless.new headless.start browser = Watir::Browser.new :chrome browser.goto ' ... browser.close headless.destroy Good luck!
1Running on Ubuntu 12.10, I also had the error message:
unable to connect to chromedriver Wasn't working even after I downloaded it and installed it correctly. I even tried using the chromedriver-helper gem. So I ran chromedriver manually (/usr/bin/chromedriver) and found out 2 things:
1) I had a missing package dependency on libnss3 which was fixed using sudo apt-get install libnss3
2) Version 2.9 of chromedriver (latest as of Feb 2014) requires chrome > version 31, and I had v25, which was fixed using sudo apt-get --only-upgrade install google-chrome-stable
mac osx 10.9.4, jruby 1.7.6, selenium-webdriver 2.42.0, brew install chromedriver -> installed 2.10
got unable to connect to chromedriver (Selenium::WebDriver::Error::WebDriverError) We have patched webdriver/chrome/service.rb to contain
@process.io.stdout = Tempfile.new("chromdriver-output") before @process.start which SOLVED the issue - crikey!
0mac osx 10.10 with jruby 1.7.12
unable to connect to chromedriver module Selenium module WebDriver module Chrome class Service alias_method :old_start, :start def start @process.io.stdout = Tempfile.new("chromdriver-output") old_start end end end end end 1On OS X? Using Brew? Missed the instructions?
$>> brew info chromedriver chromedriver: stable 2.20 ... ==> Caveats To have launchd start chromedriver at login: ln -sfv /usr/local/opt/chromedriver/*.plist ~/Library/LaunchAgents Then to load chromedriver now: launchctl load ~/Library/LaunchAgents/homebrew.mxcl.chromedriver.plist Follow them :) worked for me. Also helps to open chrome, it might need updating.
1i had some issue when configurate circle ci
- add to Gemfile interface for Xvfb
gem 'headless', '~> 2.3.1'
- add to spec/rails_spec.rb
if ENV['HEADLESS'] == 'on' require 'headless' headless = Headless.new headless.start end
so run your rspec by HEADLESS=on bundle exec rspec
Example of the working configuration where this problem is solved:
circle.yml
- reinstall Chrome
- install ChromeDriver
- install Selenium
Here's an excellent manual how to do it:
1ubuntu-14-04-x64
unable to connect to chromedriver 127.0.0.1:9515
$ chromedriver -v ChromeDriver 2.33.506092 $ which chromedriver /usr/local/bin/chromedriver wget -N unzip chromedriver_linux64.zip chmod +x chromedriver sudo mv -f chromedriver /usr/local/share/chromedriver sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver ___ Capybara.register_driver(:headless_chrome) do |app| capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( chromeOptions: { args: %w[headless disable-gpu --screen-size=1024x640] } ) Capybara::Selenium::Driver.new( app, browser: :chrome, desired_capabilities: capabilities ) end Capybara.javascript_driver = :headless_chrome Capybara.current_driver = :headless_chrome This worked for me:
- Update chrome chromedriver-update 2.42
- Check Version chromedriver -v
- Search Chromedriver which chromedriver
- Remove chromedriver
rm
which chromedriver - Remove Chromedriver and install new one
1- rm chromedriver and Download chromedriver
2- unzip chromedriver_mac64\ (2).zip
3- echo $APTH (Check your path for executable bin)
4- mv chromedriver /usr/local/bin (Place to the bin)
If the above solutions doesn't work, try creating another gemset and execute tests
rvm gemset create <your_gemset_name> rvm gemset use <your_gemset_name> gem install bundler bundle install Because this issue usually happens whenever there are conflicts between two versions of selenium-webdriver