80

Getting the following error when running rspec tests

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

Using latest ruby (1.9.2) and firefox (6.0)

Using rspec-rails, capybara and several other gems, but they don't seem to be a problem. These tests run fine in another environment (linux).

apneadiving
  • 114,565
  • 26
  • 219
  • 213
Srini K
  • 3,315
  • 10
  • 37
  • 47

8 Answers8

98

[Update - this can (was for me) still be a fix for this issue in 2015 |mdurrant|]

I came across this problem lately.

You should upgrade to capybara v1.0.1 to have a correct selenium webdriver.

To be sure I added:

gem 'selenium-webdriver', '2.25.0'

in my Gemfile.

Important note:
The selenium-webdriver gem is updated, and a new version released, for every subsequent version of Firefox. Presently, version 2.25.0 is needed to support Firefox 15.

Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
apneadiving
  • 114,565
  • 26
  • 219
  • 213
  • 11
    I actually did 'bundle update selenium-webdriver', but either way the goal is to update selenium-webdriver gem to 2.5.0. The tests ran fine after the update. – Srini K Sep 01 '11 at 16:00
  • just did. sorry for the delay. – Srini K Sep 08 '11 at 21:26
  • 1
    had to do - gem 'selenium-webdriver', '>= 2.5.0' - for firefox 11. this got me gem version 2.10... – ZX12R Mar 19 '12 at 12:33
  • 7
    And selenium-webdriver 2.31.0 is needed for Firefox 19. Seems like the answer is always, "get the latest selenium-webdriver." – jwadsack Mar 26 '13 at 22:06
  • I always just leave the version number off of `selenium-webdriver` and do `bundle update selenium-webdriver` when the version needs updating. – Jason Swett Mar 04 '15 at 21:22
17

I couldn't get it to work with Firefox 10 on Ubuntu. Switching to Chrome helped.

Install Chrome Driver.

spec_helper.rb:

Capybara.register_driver :selenium_chrome do |app|   
  Capybara::Selenium::Driver.new(app, :browser => :chrome)
end

In your spec:

Capybara.current_driver = :selenium_chrome
... tests ...
Capybara.use_default_driver
Vincent
  • 16,086
  • 18
  • 67
  • 73
12

For anybody experiencing this with Firefox 12, the current selenium webdriver (2.21) doesn't support FF12. The only solution I have found is to continue using Firefox is to downgrade Firefox, until selenium-webdriver is updated with FF12 support.

This can be done using synaptic package manager by selecting the Firefox package, and clicking Package menu > Force Version > select an earlier version. Then apply changes.

If you don't have synaptic, you can install it with apt-get install synaptic.

Update: Firefox 12 support was added in 2.22 and FF13 support was added in 2.23

mltsy
  • 6,598
  • 3
  • 38
  • 51
10

I was getting this error because the specs were being run on a headless server. This meant there was no display for the browser to render onto.

This article suggests using a virtual X server (X Virtual Framebuffer). This allows the browser to render in a virtual display.

Install like so:

sudo apt-get install xvfb
sudo apt-get install x11-xkb-utils
sudo apt-get install xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic

Then run the specs with the command xvfb-run in front.

xvfb-run bundle exec rake spec:features

This was the SO answer that lead me to the above article. It also gives an alternative means to use Xvfb.

Community
  • 1
  • 1
br3nt
  • 9,017
  • 3
  • 42
  • 63
3

*/var/lib/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/firefox/launcher.rb:79:in `connect_until_stable': unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055)(Selenium::WebDriver::Error::WebDriverError)*

I had the same problem, updating the selenium-webdriver did not help (it was the most current version available already).

It turns out, that I tried to run my script from an SSH session, and $DISPLAY was not set.

The problem was fixed with:

export DISPLAY=:0

before starting my Ruby script from the SSH session (use echo $DISPLAY in a terminal on the X session to find out what you need to put into this variable).

Werner
  • 2,537
  • 1
  • 26
  • 38
pi3g.com
  • 31
  • 1
2
bundle update selenium-webdriver
rusllonrails
  • 5,586
  • 3
  • 34
  • 27
1

Adding the 'launchy' gem to my application's Gemfile worked with FF13.0, Capybara & Selenium v1.8.24.

mnoble01
  • 579
  • 5
  • 16
  • 1
    I suspect that if this fixed the issue, it would only be because adding launchy caused a later version of capybara to be pulled in (e.g. as a dependency). – Stefan Magnuson Sep 16 '14 at 02:06
0

This is only a reiteration of what everyone was saying above. I checked my gemfile and made sure that the 'selenium-webdriver' didn't have any limits on it then ran a 'bundle update' and it worked.

I'm on ubuntux64 and windows 8 x64

Austio
  • 5,939
  • 20
  • 34