私の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
spec/requests/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: 安定した Firefox 接続を 60 秒で取得できません (127.0.0.1:7055)
私はセレンの多くのバージョンを試しましたが、まだ修正していません...この種の問題を解決するための貴重な提案をしてください。
ありがとう