Unable to obtain stable firefox connection in 60 s

2019-01-08 12:04发布

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.

12条回答
狗以群分
2楼-- · 2019-01-08 12:17

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
查看更多
Emotional °昔
3楼-- · 2019-01-08 12:17

Downgrade Firefox.

If already using gem 'headless' and updating gems is not desirable as for right now, then you need to downgrade firefox.

For Ubuntu (but other linux distros would be pretty similar) you should:

Remove firefox that comes with Ubuntu latest versions

sudo apt-get purge firefox

You can complement with removing some associated data as explained here

Now, install an older version of Firefox. For me, version 42.0 worked (as our Travis.ci uses it)

$ export FIREFOX_SOURCE_URL='https://download.mozilla.org/?product=firefox-42.0&lang=en-US&os=linux64'
$ wget --no-verbose -O /tmp/firefox-42.0.tar.bz2 $FIREFOX_SOURCE_URL
$ tar xvC ~/. -f /tmp/firefox-42.0.tar.bz2
ln -s ~/firefox/firefox ~/bin/firefox

Open a new terminal tab and run your cucumber specs/selenium specs.

You can now download the newest version of Firefox and create a .desktop file in /usr/share/applications/ to access it from the dock. And let Selenium find by default the older version. Take this for reference

查看更多
戒情不戒烟
4楼-- · 2019-01-08 12:24
bundle update selenium-webdriver
查看更多
Rolldiameter
5楼-- · 2019-01-08 12:25

for anyone using Vagrant, if you log in enabling XServer firefox can start correctly which solved it for me. vagrant ssh -- -X

查看更多
我命由我不由天
6楼-- · 2019-01-08 12:27

If the above does now work, like in my case, give this a shot.

I was getting the time out error on one machine and not another. Both machines are thin clients running the exact same versions of everything. So that ruled out incompatible firefox versions (error occured on one machine and not the other)

Turned out that there was an issue with the port that headless was using. There was another process using that port.

The below fixed the issue for me:
Add the following line in the .zshenv file
export XVFB_DISPLAY='new-port-number'
then run command zsh in terminal to set change

查看更多
ら.Afraid
7楼-- · 2019-01-08 12:28

This error happens when selenium and firefox versions are incompatible.

There are two options.

  1. Update selenium:

    gem update selenium-webdriver

    If it still fails, then selenium hasn't been updated to the newest version.

  2. Downgrade the version of firefox:

    sudo apt-get purge firefox

    To see the available packages for download apt-cache showpkg firefox

    sudo apt-get install firefox=#older_version#

查看更多
登录 后发表回答