1

在我的 Gemfile 中,我使用了

group :development, :test do 
  gem 'rspec-rails' 
  gem 'factory_girl_rails' 
  gem 'capybara', :git => 'git://github.com/jnicklas/capybara.git'
  gem 'launchy'
end 

group :test do
  gem 'faker'
  gem 'guard-rspec'
  gem 'selenium-webdriver', '2.35.1' 

  # gem 'capybara-webkit'
  gem 'database_cleaner'
end

在 spec/spec_helper.rb

# This file is copied to spec/ when you run 'rails generate rspec:install'

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__) 
require 'rspec/rails'
require 'rspec/autorun'

require 'capybara/rspec'
require 'capybara/rails'

  Capybara.default_driver = :selenium

  Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }

  ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)

  RSpec.configure do |config|

    config.include Capybara::DSL

    config.use_transactional_fixtures = true

    config.infer_base_class_for_anonymous_controllers = false


    config.order = "random"
  end

在规范/请求/home_spec.rb

describe "Homepage with 'Government Contracts Awarded By Year'", :js => true do
  it  "should have visible" do 
     visit root_path
     page.has_content?('Government Contracts Awarded By Year')
  end

  it "Graph View", :driver => :selenium do 
    page.has_css?('#ui-id-1')
    # $("#by_year_tabs ul li a#ui-id-1").text()
    click_link 'ui-id-1'
  end

  it "Table View", :driver => :selenium do  
    page.has_css?('#ui-id-2')
    # click_link 'ui-id-2'
    page.has_selector?(:xpath, '//table/tr')
  end
end

当我在终端上运行这个测试时,我得到了错误

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

我已经尝试了许多版本的 selenium,但还没有修复...请提供有价值的建议来解决此类问题,我在 vagrant 中,我已经安装了 firefox 以及 crome 设置。

谢谢

4

2 回答 2

0

当您使 Firefox 保持最新状态时,我曾经遇到过此错误。

Selenium webdriver 还不兼容最新的 FF 版本。

您应该尝试下载以前的 FF 版本https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/

为了避免这个问题,我在 FF 应用程序上锁定了我的 FF 应用程序:Cmd + i 并在 MacOsx 上单击 Locked。

当您升级 selenium gem 时,您还可以将您的 FF 升级到最后一个受支持的。

于 2013-09-23T15:40:05.127 回答
0

也许这个答案可以解决你的问题:Unable to get stable firefox connection in 60 seconds (127.0.0.1:7055)

简要地:

gem update selenium-webdriver
于 2013-09-20T10:29:16.783 回答