tsinghan
tsinghan

Reputation: 437

unable to connect to chromedriver

I use capybara & selenium to test my rails project. When I execute the test script, it 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 googled how to use Google Chrome as the testing browser instead of Firefox

but it causes other errors like:

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

Upvotes: 40

Views: 40436

Answers (10)

Jeremy
Jeremy

Reputation: 745

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

Upvotes: 58

vishal Singh
vishal Singh

Reputation: 51

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)

Upvotes: 1

serhiy
serhiy

Reputation: 11

ubuntu-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 http://chromedriver.storage.googleapis.com/2.33/chromedriver_linux64.zip

    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

Upvotes: 1

Prashanth Sams
Prashanth Sams

Reputation: 21129

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

Upvotes: 0

Alex Strizhak
Alex Strizhak

Reputation: 990

i 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: https://gist.github.com/ziadoz/3e8ab7e944d02fe872c3454d17af31a5

Upvotes: 1

Volte
Volte

Reputation: 1905

On 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.

Upvotes: 2

Gaurav Shah
Gaurav Shah

Reputation: 5279

mac osx 10.10 with jruby 1.7.12

unable to connect to chromedriver http://127.0.0.1:9515

found this-> https://code.google.com/p/selenium/issues/detail?id=6574#c3

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

Upvotes: 2

Bill Sloane
Bill Sloane

Reputation: 61

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 http://127.0.0.1:9515
(Selenium::WebDriver::Error::WebDriverError)

found this-> https://code.google.com/p/selenium/issues/detail?id=6574#c3

We have patched webdriver/chrome/service.rb to contain

@process.io.stdout = Tempfile.new("chromdriver-output")
before @process.start

which SOLVED the issue - crikey!

Upvotes: 2

stuartpalmer
stuartpalmer

Reputation: 156

Running on Ubuntu 12.10, I also had the error message:

unable to connect to chromedriver http://127.0.0.1:9515

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

Upvotes: 10

Mikhail Chuprynski
Mikhail Chuprynski

Reputation: 2493

On 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 - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sh -c 'echo "deb http://dl.google.com/linux/chrome/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 http://chromedriver.storage.googleapis.com/2.7/chromedriver_linux64.zip
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 'http://google.com'

...

browser.close
headless.destroy

Good luck!

Upvotes: 11

Related Questions