Ruby-on-rails 无法在 60 秒内获得稳定的 Firefox 连接 (127.0.0.1:7055)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14303161/
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 Panjiyar Rahul
While testing scenario by cucumberi'm getting the following error when running rspectests
在测试场景时,cucumber我在运行rspec测试时收到以下错误
unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055) (Selenium::WebDriver::Error::WebDriverError)
无法在 60 秒内获得稳定的 firefox 连接 (127.0.0.1:7055) (Selenium::WebDriver::Error::WebDriverError)
Using ruby (1.9.2)selenium-webdriver (2.27.2)and firefox (19.0)
使用ruby (1.9.2)selenium-webdriver (2.27.2)和firefox (19.0)
Using rspec-rails (2.12.1), capybara (2.0.2)and several other gems, Also i have added launchygem but they don't seem to be a problem. And i am using Windows 7.
使用rspec-rails (2.12.1),capybara (2.0.2)和其他几个 gem,我也添加了launchygem,但它们似乎不是问题。我正在使用Windows 7.
回答by ballPointPenguin
I had the same problem (on Linux). Fixed with:
我遇到了同样的问题(在 Linux 上)。固定:
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
现在我使用 ruby 1.9.3-p286、selenium-webdriver 2.29.0、firefox 18.0 以及 rspec-rails 2.9.0、capybara 1.1.2 和 capybara-webkit 0.12.1
I added selenium-webdriver 2.29.0 to my Gemfile to be safe.
为了安全起见,我将 selenium-webdriver 2.29.0 添加到我的 Gemfile 中。
回答by Mark Berry
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:
Selenium Webdriver 似乎经常更新以跟上 Firefox。但是你怎么知道你需要哪个版本呢?希望即使版本发生变化,此过程也能正常工作:
Scroll down to Selenium Client & WebDriver Language Bindings.
In that section, in the Rubylanguage line, click on "Change Log" (direct link).
In the Change Log, determine which version of Selenium you need for your version of Firefox.
向下滚动到Selenium 客户端和 WebDriver 语言绑定。
在该部分的Ruby语言行中,单击“更改日志”(直接链接)。
在更改日志中,确定您的 Firefox 版本需要哪个 Selenium 版本。
If you're using Bundler, run bundle show selenium-webdriverto see which version you have. To update, for example to 2.35.0, add this line to your Gemfile:
如果您使用的是 Bundler,请运行bundle show selenium-webdriver以查看您使用的是哪个版本。要更新,例如更新到 2.35.0,请将此行添加到您的Gemfile:
gem 'selenium-webdriver', '2.35.0'
and then run bundle updateto install. If you are using Spork, remember to re-start it before re-running your tests.
然后运行bundle update安装。如果您使用的是 Spork,请记住在重新运行测试之前重新启动它。
UpdateOne StackOverflow answerindicates 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.
更新StackOverflow 的一个回答表明,源代码存储库中的更改日志可能比 seleniumhq.org 中的更新日志更新得更快。Ruby 的存储库更改日志在这里:https: //github.com/SeleniumHQ/selenium/blob/master/rb/CHANGES。
Downgrading Firefox
降级火狐
If you need to downgrade Firefox on Ubuntu 12.04, this answerexplains 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 answerto put Firefox updates on hold until Selenium releases an update that works with the later version of Firefox.
如果您需要在 Ubuntu 12.04 上降级 Firefox,此答案解释了如何返回到 Firefox 20。此处提供了有关切换到任何版本 Firefox 的方法的更一般描述。然后使用此答案暂停 Firefox 更新,直到 Selenium 发布适用于更高版本 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!
就我而言,我降级 Firefox 只是为了发现 Selenium Webdriver 最近已更新以处理最新版本,因此请先检查 Selenium 更新!
回答by rusllonrails
bundle update selenium-webdriver
回答by Matt Gibson
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.
刚在CI服务器上碰到这个,发现是因为火狐没有显示器可以用。我原以为 selenium webdriver 可以让它在没有进一步干预的情况下工作,但事实并非如此。
Adding Xvfb into the mix made it work.
将 Xvfb 添加到混合物中使其起作用。
For Rails running Cucumber features:
对于运行 Cucumber 的 Rails 功能:
gem 'headless'
then in features/support/env.rb
然后在 features/support/env.rb
Before do
if Capybara.current_driver == :selenium
require 'headless'
headless = Headless.new
headless.start
end
end
回答by pgerstoft
This error happens when selenium and firefox versions are incompatible.
当 selenium 和 firefox 版本不兼容时会发生此错误。
There are two options.
有两种选择。
Update selenium:
gem update selenium-webdriverIf it still fails, then selenium hasn't been updated to the newest version.
Downgrade the version of firefox:
sudo apt-get purge firefoxTo see the available packages for download
apt-cache showpkg firefoxsudo apt-get install firefox=#older_version#
更新硒:
gem update selenium-webdriver如果仍然失败,则说明 selenium 尚未更新到最新版本。
降级firefox版本:
sudo apt-get purge firefox查看可供下载的软件包
apt-cache showpkg firefoxsudo apt-get install firefox=#older_version#
回答by orion
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)
我在一台机器上而不是另一台机器上出现超时错误。两台机器都是运行完全相同版本的瘦客户端。这样就排除了不兼容的 Firefox 版本(错误发生在一台机器上,而不是另一台机器上)
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 .zshenvfileexport XVFB_DISPLAY='new-port-number'
then run command zshin terminal to set change
下面为我解决了这个问题:
在.zshenv文件中添加以下行,export XVFB_DISPLAY='new-port-number'
然后zsh在终端中运行命令以设置更改
回答by Shiprack
The magic combination that worked for me was Firefox 19.0 and selenium web-driver 2.32.1 (latest at the time of writing). Firefox 20.x and 21.x did not work. I had to downgrade Firefox. Also keep in mind that (at least on Mac OS), if you go to FireFox Menu -> About Firefox, it will automatically upgrade to the latest release. Don't do that.
对我有用的神奇组合是 Firefox 19.0 和 selenium web-driver 2.32.1(在撰写本文时最新)。Firefox 20.x 和 21.x 不起作用。我不得不降级 Firefox。还要记住(至少在 Mac OS 上),如果您转到 FireFox 菜单 -> 关于 Firefox,它会自动升级到最新版本。不要那样做。
回答by ttguy
I had this issue when I was starting irb from a terminal where I had su ed my self to another user. I would get this error when I ran irb as that user. But not if I ran as root. And not when I exited back out to a shell owned by the logged in user.
当我从一个终端启动 irb 时,我遇到了这个问题,我已经将自己起诉给另一个用户。当我以该用户身份运行 irb 时,我会收到此错误。但如果我以 root 身份运行,则不会。而不是当我退出回登录用户拥有的 shell 时。
回答by Ben
for anyone using Vagrant, if you log in enabling XServer firefox can start correctly which solved it for me. vagrant ssh -- -X
对于使用 Vagrant 的任何人,如果您登录启用 XServer firefox 可以正确启动,这为我解决了它。无业游民 ssh -- -X
回答by Alexander Williamson
For me, I had already updated the gems but then needed to update my bundle.
对我来说,我已经更新了 gems,但随后需要更新我的包。
In powershell, navigate to your directory then update the bundle:
在 powershell 中,导航到您的目录,然后更新包:
cd D:\Projects\LazyAutomation
bundle update

