无法在60秒内获得稳定的firefox连接(127.0.0.1:7055)

Pan*_*hul 74 ruby-on-rails cucumber capybara rspec-rails selenium-webdriver

在测试场景时,cucumber我在运行rspec测试时遇到以下错误

无法在60秒内获得稳定的firefox连接(127.0.0.1:7055)(Selenium :: WebDriver :: Error :: WebDriverError)

使用ruby (1.9.2) selenium-webdriver (2.27.2)firefox (19.0)

使用rspec-rails (2.12.1),capybara (2.0.2)和其他几个宝石,我也添加了launchy宝石,但他们似乎没有问题.而我正在使用Windows 7.

bal*_*uin 87

我遇到了同样的问题(在Linux上).修正:

gem update selenium-webdriver
Run Code Online (Sandbox Code Playgroud)

现在我使用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

为了安全起见,我将selenium-webdriver 2.29.0添加到我的Gemfile中.

  • 这不应该是批准的答案.http://stackoverflow.com/a/18263152/712188是更正确的答案. (4认同)

Mar*_*rry 46

似乎Selenium Webdriver经常更新以跟上Firefox.但是你怎么知道你需要哪个版本?希望这个过程即使在版本更改时也能正常工作:

  1. 访问http://www.seleniumhq.org/download/.

  2. 向下滚动到Selenium Client和WebDriver语言绑定.

  3. 在该部分中,在Ruby语言行中,单击"更改日志"(直接链接).

  4. 在更改日志中,确定您的Firefox版本所需的Selenium版本.

如果您使用的是Bundler,请运行bundle show selenium-webdriver以查看您拥有的版本.要更新,例如更新到2.35.0,请将此行添加到您的Gemfile:

gem 'selenium-webdriver', '2.35.0'
Run Code Online (Sandbox Code Playgroud)

然后运行bundle update安装.如果您正在使用Spork,请记住在重新运行测试之前重新启动它.

更新 一个StackOverflow答案表明更改日志可能在源代码存储库中比在seleniumhq.org更快更新.Ruby的存储库更改日志位于:https: //github.com/SeleniumHQ/selenium/blob/master/rb/CHANGES.

降级Firefox

如果您需要在Ubuntu 12.04上降级Firefox,这个答案将解释如何返回到Firefox 20. 此处给出切换到任何版本Firefox的更一般描述.然后使用此答案暂停Firefox更新,直到Selenium发布可与更高版本的Firefox一起使用的更新.

在我的情况下,我降级Firefox仅发现Selenium Webdriver最近已更新以处理最新版本,因此请先检查Selenium更新!


rus*_*ils 10

bundle update selenium-webdriver
Run Code Online (Sandbox Code Playgroud)


Mat*_*son 9

刚刚在CI服务器上遇到这个问题,发现这是因为Firefox没有显示器可供使用.我原以为selenium webdriver会让它无需进一步干预就可以工作但事实并非如此.

将Xvfb添加到混合中使其工作.

对于运行Cucumber功能的Rails:

gem 'headless'
Run Code Online (Sandbox Code Playgroud)

然后在features/support/env.rb中

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

    headless = Headless.new
    headless.start
  end
end
Run Code Online (Sandbox Code Playgroud)