Ruby-on-rails 无法在 60 秒内获得稳定的 Firefox 连接 (127.0.0.1:7055)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7263564/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055)
提问by Srini K
Getting the following error when running rspec tests
运行 rspec 测试时出现以下错误
unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055) in rails
无法在 60 秒内 (127.0.0.1:7055) 在 rails 中获得稳定的 Firefox 连接
Using latest ruby (1.9.2) and firefox (6.0)
使用最新的 ruby (1.9.2) 和 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).
使用 rspec-rails、capybara 和其他几个 gem,但它们似乎不是问题。这些测试在另一个环境 (linux) 中运行良好。
回答by apneadiving
[Update - this can (was for me) still be a fix for this issue in 2015|mdurrant|]
[更新 - 这可以(对我来说)仍然是2015 年此问题的解决方案|mdurrant|]
I came across this problem lately.
You should upgrade to capybara v1.0.1 to have a correct selenium webdriver.
您应该升级到 capybara v1.0.1 以获得正确的 selenium webdriver。
To be sure I added:
可以肯定的是,我添加了:
gem 'selenium-webdriver', '2.25.0'
in my Gemfile.
在我的 Gemfile 中。
Important note:
The selenium-webdrivergem is updated, and a new version released, for every subsequent version of Firefox. Presently, version 2.25.0is needed to support Firefox 15.
重要提示:
对于selenium-webdriverFirefox 的每个后续版本,gem 都会更新,并发布一个新版本。目前,2.25.0需要支持Firefox 15 的版本。
回答by Vincent
I couldn't get it to work with Firefox 10 on Ubuntu. Switching to Chrome helped.
我无法让它在 Ubuntu 上与 Firefox 10 一起使用。切换到 Chrome 有帮助。
Install Chrome Driver.
安装Chrome 驱动程序。
spec_helper.rb:
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
回答by mltsy
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.
对于使用 Firefox 12 遇到此问题的任何人,当前的 selenium webdriver (2.21) 不支持 FF12。我发现的唯一解决方案是继续使用 Firefox 是降级 Firefox,直到 selenium-webdriver 更新为 FF12 支持。
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.
这可以使用突触包管理器完成,方法是选择 Firefox 包,然后单击包菜单 > 强制版本 > 选择较早的版本。然后应用更改。
If you don't have synaptic, you can install it with apt-get install synaptic.
如果你没有synaptic,你可以用apt-get install synaptic 安装它。
Update: Firefox 12 support was added in 2.22 and FF13 support was added in 2.23
更新:Firefox 12 支持已在 2.22 中添加,FF13 支持已在 2.23 中添加
回答by br3nt
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 articlesuggests using a virtual X server (X Virtual Framebuffer). This allows the browser to render in a virtual display.
本文建议使用虚拟 X 服务器(X Virtual Framebuffer)。这允许浏览器在虚拟显示中呈现。
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-runin front.
然后使用xvfb-run前面的命令运行规范。
xvfb-run bundle exec rake spec:features
This was the SO answerthat lead me to the above article. It also gives an alternative means to use Xvfb.
回答by pi3g.com
*/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)*
*/var/lib/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/firefox/launcher.rb:79:in `connect_until_stable': 无法在 60 秒内获得稳定的 firefox 连接(127.0.0.1:7055)(Selenium::WebDriver::Error::WebDriverError)*
I had the same problem, updating the selenium-webdriverdid not help (it was the most current version available already).
我遇到了同样的问题,更新selenium-webdriver没有帮助(它已经是可用的最新版本)。
It turns out, that I tried to run my script from an SSH session, and $DISPLAYwas not set.
事实证明,我试图从 SSH 会话运行我的脚本,$DISPLAY但没有设置。
The problem was fixed with:
问题已解决:
export DISPLAY=:0
before starting my Ruby script from the SSH session (use echo $DISPLAYin a terminal on the X session to find out what you need to put into this variable).
在从 SSH 会话启动我的 Ruby 脚本之前(echo $DISPLAY在 X 会话的终端中使用以找出需要放入此变量的内容)。
回答by rusllonrails
bundle update selenium-webdriver
回答by mnoble01
Adding the 'launchy' gem to my application's Gemfile worked with FF13.0, Capybara & Selenium v1.8.24.
将“launchy”gem 添加到我的应用程序的 Gemfile 中,可与 FF13.0、Capybara 和 Selenium v1.8.24 一起使用。
回答by Austio
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.
这只是对上面每个人所说的话的重申。我检查了我的 gemfile 并确保“selenium-webdriver”没有任何限制,然后运行“捆绑更新”并且它起作用了。
I'm on ubuntux64 and windows 8 x64
我在 ubuntux64 和 windows 8 x64

