【发布时间】:2014-09-27 09:56:16
【问题描述】:
我对 Capybara 很陌生,以前也从未使用过 Selenium。我正在 MacOSX 上做一个 ruby on rails 项目,无论出于何种原因,当我运行测试时,浏览器窗口永远不会打开。 我的堆栈是:Capybara、Selenium、Rspec、Ruby on Rails。 我的测试如下:
describe 'Downloads', js: true do
context ' compress zip and download file' do
before do
Capybara.current_driver = :selenium
session = Capybara::Session.new(:selenium)
session.visit '/users/sign_in'
find('#tab_signin').click
within("#new_user") do
fill_in 'user_login', :with => 'admin@local.host'
fill_in 'user_password', :with => 'password'
end
click_button 'Sign in'
end
it 'downloads the project and navigates to downloads page' do
visit 'some/path'
within '.create-download' do
find(:select).find("option[value='zip']").select_option
end
sleep 3
page.should have_css('#download-modal.in')
end
结束 结束
我还尝试将 features/support/env.rb 中的内容更改为:
Capybara.javascript_driver = :selenium
Capybara.register_driver :selenium do |app|
profile = Selenium::WebDriver::Firefox::Profile.new
Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => profile)
end
更新
不仅浏览器没有打开,而且测试失败,输出如下:
Failure/Error: visit '/users/sign_in'
ArgumentError:
unknown option: {:resynchronize=>true}
【问题讨论】:
-
将
features/support/env.rb的内容移动到spec/spec_helper.rb -
你的测试是失败了还是没有打开浏览器?
-
@jkeuhlen 请查看更新。
标签: javascript ruby-on-rails selenium rspec capybara