我正在使用 RSpec、Capybara 和 Selenium(使用的驱动程序:webkit 和 poltergeist)测试我的 Ruby on Rails 3.2 应用程序。
我将尝试测试以下代码:
scenario 'ask a question', js: true do
visit group_path(@group, locale: 'en')
find('#question_subject').set 'A new question'
find('#question_content').set 'The content of the question'
find('#question_tag_tokens', visible: false).set @tag.id
find('#submit').click
expect(page).to have_content 'A new question'
end
但是当我尝试运行测试时,我会收到以下错误:
1) Interact with group ask a question
Failure/Error: find('#question_subject').set 'A new question'
Selenium::WebDriver::Error::JavascriptError:
waiting for evaluate.js load failed
# [remote server] file:///var/folders/gz/svmw_f_n73q9z25trgsp_tnm0000gn/T/webdriver-profile20130806-4190-1l8e4c4/extensions/fxdriver@googlecode.com/components/driver_component.js:8360:in `r'
# [remote server] file:///var/folders/gz/svmw_f_n73q9z25trgsp_tnm0000gn/T/webdriver-profile20130806-4190-1l8e4c4/extensions/fxdriver@googlecode.com/components/driver_component.js:392:in `fxdriver.Timer.prototype.runWhenTrue/g'
# [remote server] file:///var/folders/gz/svmw_f_n73q9z25trgsp_tnm0000gn/T/webdriver-profile20130806-4190-1l8e4c4/extensions/fxdriver@googlecode.com/components/driver_component.js:386:in `fxdriver.Timer.prototype.setTimeout/<.notify'
# ./spec/features/groups_spec.rb:93:in `block (2 levels) in <top (required)>
在 spec_helper.rb 文件中有 DatabaseCleaner 的附加行:
config.use_transactional_fixtures = false
config.before(:suite) do
DatabaseCleaner.clean_with :truncation
end
config.before(:each) do
if example.metadata[:js]
DatabaseCleaner.strategy = :truncation
else
DatabaseCleaner.strategy = :transaction
end
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
我无法解决这个问题。我正在尝试不同的驱动程序来测试 javascript:poltergeist 和 capybara-webkit。但我得到同样的错误。希望您能够帮助我。