Unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055)

While testing scenario by cucumber i'm getting the following error when running rspec tests

unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055) (Selenium::WebDriver::Error::WebDriverError)

Using ruby (1.9.2) selenium-webdriver (2.27.2) and firefox (19.0)

Using rspec-rails (2.12.1), capybara (2.0.2) and several other gems, Also i have added launchy gem but they don't seem to be a problem. And i am using Windows 7.


Solution 1:

I had the same problem (on Linux). Fixed with:

gem update selenium-webdriver

Now I am using ruby 1.9.3-p286, selenium-webdriver 2.29.0, firefox 18.0 As well as rspec-rails 2.9.0, capybara 1.1.2, and capybara-webkit 0.12.1

I added selenium-webdriver 2.29.0 to my Gemfile to be safe.

Solution 2:

It seems Selenium Webdriver gets frequent updates to keep up with Firefox. But how do you know which version you need? Hopefully this procedure will work even as versions change:

  1. Go to http://www.seleniumhq.org/download/.

  2. Scroll down to Selenium Client & WebDriver Language Bindings.

  3. In that section, in the Ruby language line, click on "Change Log" (direct link).

  4. In the Change Log, determine which version of Selenium you need for your version of Firefox.

If you're using Bundler, run bundle show selenium-webdriver to see which version you have. To update, for example to 2.35.0, add this line to your Gemfile:

gem 'selenium-webdriver', '2.35.0'

and then run bundle update to install. If you are using Spork, remember to re-start it before re-running your tests.

Update One StackOverflow answer indicates that the Change Log may be updated sooner in the source code repository than at seleniumhq.org. The repository Change Log for Ruby is here: https://github.com/SeleniumHQ/selenium/blob/master/rb/CHANGES.

Downgrading Firefox

If you need to downgrade Firefox on Ubuntu 12.04, this answer explains how to go back to Firefox 20. A more general description of a way to switch to any version of Firefox is given here. Then use this answer to put Firefox updates on hold until Selenium releases an update that works with the later version of Firefox.

In my case, I downgraded Firefox only to discover that Selenium Webdriver had recently been updated to handle the latest version, so check for Selenium updates first!

Solution 3:

bundle update selenium-webdriver

Solution 4:

Just ran into this on the CI server and found that it was because Firefox had no display to use. I had thought that selenium webdriver would make it work with no further intervention but this was not the case.

Adding Xvfb into the mix made it work.

For Rails running Cucumber features:

gem 'headless'

then in features/support/env.rb

Before do
  if Capybara.current_driver == :selenium
    require 'headless'

    headless = Headless.new
    headless.start
  end
end