Skip to content
This repository has been archived by the owner on Apr 1, 2019. It is now read-only.

Error: unable to connect to chromedriver http://127.0.0.1:9515 (Selenium::WebDriver::Error::WebDriverError) #44

Closed
aruprakshit opened this issue Jun 27, 2017 · 15 comments

Comments

@aruprakshit
Copy link

File name: sign_in_spec.rb

require "spec_helper"

RSpec.describe "the signin process", :type => :feature do

  it "signs me in" do
    visit '/'
    expect(page).to have_content 'About Zeit.io'
  end
end

File name: spec_helper.b

require "bundler/setup"
require "capybara/rspec"
require "selenium-webdriver"
require "frontend_end_to_end"


RSpec.configure do |config|
  # Enable flags like --only-failures and --next-failure
  config.example_status_persistence_file_path = ".rspec_status"

  config.expect_with :rspec do |c|
    c.syntax = :expect
  end

  # config.before(:each, type: :feature) do
  #   # Note (Mike Coutermarsh): Make browser huge so that no content is hidden during tests
  #   Capybara.current_session.driver.browser.manage.window.resize_to(2_500, 2_500)
  # end
end

Capybara.register_driver :selenium do |app|
  Capybara::Selenium::Driver.new(
    app,
    browser: :chrome,
    switches: %w[--ignore-certificate-errors --disable-popup-blocking])
end

Capybara.javascript_driver = :chrome

Capybara.configure do |config|
  config.default_max_wait_time = 20 # seconds
  config.default_driver        = :selenium
end

Capybara.app_host = 'http://127.0.0.1:8080/'

When I ran rspec spec, got the below error:

the signin process
2017-06-27 18:42:12 WARN Selenium [DEPRECATION] :args or :switches is deprecated. Use Selenium::WebDriver::Chrome::Options#add_argument instead.
  signs me in (FAILED - 1)

Failures:

  1) the signin process signs me in
     Failure/Error: visit '/'

     Selenium::WebDriver::Error::WebDriverError:
       unable to connect to chromedriver 127.0.0.1:9515
     # /Users/arup/.rvm/gems/ruby-2.3.3@e2e-dockingtest-app/gems/selenium-webdriver-3.4.3/lib/selenium/webdriver/common/service.rb:130:in `connect_until_stable'
     # /Users/arup/.rvm/gems/ruby-2.3.3@e2e-dockingtest-app/gems/selenium-webdriver-3.4.3/lib/selenium/webdriver/common/service.rb:74:in `block in start'
     # /Users/arup/.rvm/gems/ruby-2.3.3@e2e-dockingtest-app/gems/selenium-webdriver-3.4.3/lib/selenium/webdriver/common/socket_lock.rb:41:in `locked'
     # /Users/arup/.rvm/gems/ruby-2.3.3@e2e-dockingtest-app/gems/selenium-webdriver-3.4.3/lib/selenium/webdriver/common/service.rb:71:in `start'
     # /Users/arup/.rvm/gems/ruby-2.3.3@e2e-dockingtest-app/gems/selenium-webdriver-3.4.3/lib/selenium/webdriver/chrome/driver.rb:52:in `initialize'
     # /Users/arup/.rvm/gems/ruby-2.3.3@e2e-dockingtest-app/gems/selenium-webdriver-3.4.3/lib/selenium/webdriver/common/driver.rb:46:in `new'
     # /Users/arup/.rvm/gems/ruby-2.3.3@e2e-dockingtest-app/gems/selenium-webdriver-3.4.3/lib/selenium/webdriver/common/driver.rb:46:in `for'
     # /Users/arup/.rvm/gems/ruby-2.3.3@e2e-dockingtest-app/gems/selenium-webdriver-3.4.3/lib/selenium/webdriver.rb:86:in `for'
     # /Users/arup/.rvm/gems/ruby-2.3.3@e2e-dockingtest-app/gems/capybara-2.14.3/lib/capybara/selenium/driver.rb:23:in `browser'
     # /Users/arup/.rvm/gems/ruby-2.3.3@e2e-dockingtest-app/gems/capybara-2.14.3/lib/capybara/selenium/driver.rb:67:in `visit'
     # /Users/arup/.rvm/gems/ruby-2.3.3@e2e-dockingtest-app/gems/capybara-2.14.3/lib/capybara/session.rb:269:in `visit'
     # /Users/arup/.rvm/gems/ruby-2.3.3@e2e-dockingtest-app/gems/capybara-2.14.3/lib/capybara/dsl.rb:50:in `block (2 levels) in <module:DSL>'
     # ./spec/signin_spec.rb:6:in `block (2 levels) in <top (required)>'

Finished in 20.27 seconds (files took 0.55112 seconds to load)
2 examples, 1 failure

Failed examples:

rspec ./spec/signin_spec.rb:5 # the signin process signs me in

/Users/arup/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/net/http.rb:882:in `rescue in block in connect': Failed to open TCP connection to 127.0.0.1:9515 (Connection refused - connect(2) for "127.0.0.1" port 9515) (Errno::ECONNREFUSED)
	from /Users/arup/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/net/http.rb:879:in `block in connect'
	from /Users/arup/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/timeout.rb:91:in `block in timeout'
	from /Users/arup/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/timeout.rb:101:in `timeout'
	from /Users/arup/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/net/http.rb:878:in `connect'
	from /Users/arup/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/net/http.rb:863:in `do_start'
	from /Users/arup/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/net/http.rb:852:in `start'
	from /Users/arup/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/net/http.rb:584:in `start'
	from /Users/arup/.rvm/gems/ruby-2.3.3@e2e-dockingtest-app/gems/selenium-webdriver-3.4.3/lib/selenium/webdriver/common/service.rb:93:in `connect_to_server'
	from /Users/arup/.rvm/gems/ruby-2.3.3@e2e-dockingtest-app/gems/selenium-webdriver-3.4.3/lib/selenium/webdriver/common/service.rb:116:in `stop_server'
	from /Users/arup/.rvm/gems/ruby-2.3.3@e2e-dockingtest-app/gems/selenium-webdriver-3.4.3/lib/selenium/webdriver/common/service.rb:79:in `stop'
	from /Users/arup/.rvm/gems/ruby-2.3.3@e2e-dockingtest-app/gems/selenium-webdriver-3.4.3/lib/selenium/webdriver/common/service.rb:69:in `block in start'
	from /Users/arup/.rvm/gems/ruby-2.3.3@e2e-dockingtest-app/gems/selenium-webdriver-3.4.3/lib/selenium/webdriver/common/platform.rb:138:in `block in exit_hook'

I am on macos sierra.
Ruby version is: ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16]
My gemspec looks like:

spec.add_development_dependency "bundler", "~> 1.14"
  spec.add_development_dependency "rake", "~> 10.0"
  spec.add_development_dependency "rspec", "~> 3.0"
  spec.add_development_dependency "capybara"
  spec.add_development_dependency "selenium-webdriver"
  spec.add_development_dependency 'chromedriver-helper', '~> 1.0'
@mathmatomancer
Copy link

I've seen a similar error just now trying to get this running on Jenkins. @aruprakshit what's the output of chromedriver -v on the system doing this? Does it give a valid response or complain about a missing library file?

@markturner
Copy link

markturner commented Jul 21, 2017

I also have this issue having recently upgraded to Sierra.

chromedriver -v says ChromeDriver 2.30.477690 (c53f4ad87510ee97b5c3425a14c0e79780cdf262)

Using 1.1 of chromedriver-helper.

For me the browser never launches.

UPDATE: I have narrowed this down to being a proxy issue. Will look into this more on Monday...

@mathmatomancer
Copy link

My problem on 2.30 was missing libraries (so even asking for the version threw an error) and I couldn't work around it on the server in question, so we backtracked to a manual install of 2.28 instead.

@mmaruri
Copy link

mmaruri commented Aug 1, 2017

I have the same problem when running on Jenkins. Where do I put this code: Chromedriver.set_version "2.28" ?

@kurotyan514
Copy link

@mmaruri
you can put Chromedriver.set_version "2.28" in your spec_helper.rb
or run chromedriver-update 2.28 in terminal

@kulte
Copy link

kulte commented Aug 10, 2017

Okay, so I'm getting this after uninstalling this too... what has this done to my machine, help?

EDIT: It stopped it running in brew services. Figured it out, wondering why it did that though.

EDIT: Um I'm still having the issue. This isn't cool...

EDIT: It makes no sense to me that somehow the following happened:

screen shot 2017-08-10 at 4 44 58 pm

@kiramclean
Copy link

Has anyone figured this out? I'm having the same problem..

@flavorjones
Copy link
Owner

@kiramclean Can you please be more specific about what problem you're encountering? This issue has some conflicting information and it's not clear to me what the OP or following users were experiencing. Feel free to open a new issue, as well.

@flavorjones
Copy link
Owner

I'm going to close this issue, because as I mentioned above, it's not clear to me that there's an issue with chromedriver-helper. If someone can clarify for me, I'm happy to reopen.

@ryanmcgarvey
Copy link

@kiramclean @kulte I had a similar issue and managed to fix it by updating chromedriver to version 2.35 and then running chromedriver-update 2.35.

@chrislopresto
Copy link

In case this helps other folks using rbenv who have experienced this issue after uninstalling... I couldn't seem to get rid of this rbenv shim:

❯ which chromedriver
/Users/xxx/.rbenv/shims/chromedriver

rbenv/rbenv#388 helped me track down the issue. I realized that I still had these chromedriver executables on disk:

❯ ls ~/.rbenv/versions/*/bin/* | grep chromedriver
/Users/xxx/.rbenv/versions/2.3.1/bin/chromedriver*
/Users/xxx/.rbenv/versions/2.3.1/bin/chromedriver-update*

After removing them, an rbenv rehash did the trick:

❯ rm ~/.rbenv/versions/2.3.1/bin/chromedriver
❯ rm ~/.rbenv/versions/2.3.1/bin/chromedriver-update
❯ rbenv rehash
❯ which chromedriver
chromedriver not found

@deivid-rodriguez
Copy link

Thanks for that tip!

This can also be a problem if you frequently switch between projects using chromedriver-helper and projects relying on the chromedriver binary being on the PATH but not using the gem. In that case, the chromedriver shims installed by this gem will make chromedriver unable to start in the other project.

Not sure how this could be properly solved, but @chrislopresto tip is really useful anyways.

@StMacLennan
Copy link

@kiramclean @kulte I had a similar issue and managed to fix it by updating chromedriver to version 2.35 and then running chromedriver-update 2.35.

This solved it for me! I simply ran chromedriver-update 2.35 in terminal and it's working! Thank you

@LucasArruda
Copy link

@StMacLennan that will probably solve the problem.

Somehow this gem is downloading a very old chromedriver (2.6/2.8), probably due to a very bad naming scheme from chrome repo.

Same thing happens when I used brew with brew cask install chromedriver. They just keep failing.

I tried almost everything and nothing helped. So I just tried "old fashioned" directly downloading binary version.

I could see that chromedriver latest is indeed 2.38. I downloaded, unzipped, moved to /usr/local/bin, chmod +x it and it's working perfectly now.

Full solution (Mac):

curl http://chromedriver.storage.googleapis.com/2.38/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

So simple!

@flavorjones
Copy link
Owner

@LucasArruda the problem you're seeing with downloading old versions of chromedriver was fixed in v0.0.8 in January 2015. Please update your gem.

In the future, you may want to consider opening a new issue for bugs that you're seeing, instead of commenting on closed tickets regarding unrelated issues. That way you can receive more direct help when you need it, and not resort to workarounds like the one you've posted above.

I'm going to go ahead and lock this ticket from further commenting.

Repository owner locked as resolved and limited conversation to collaborators May 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests