我正在为注册表单编写一个场景。
@abc
@selenium
Scenario:Non registered user signs up
Given I am on the sign-up page
When I fill in the following:
|first_name|Anidhya|
|last_name|Ahuja|
|email|anidhya@gmail.com|
|password|123456|
And I press "submit"
Then I should see "Registration complete"
对于我在env.rb文件中的内容,我写道:
begin
require 'database_cleaner'
require 'database_cleaner/cucumber'
DatabaseCleaner.strategy = :transaction
Cucumber::Rails::World.use_transactional_fixtures = true
rescue NameError
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end
Before('@abc') do
DatabaseCleaner.start
end
After('@abc') do
DatabaseCleaner.clean
end
现在,当我运行场景时,用户将被保存在数据库中,并且数据库清理器将失败。我没有看到任何错误消息
答案 0 :(得分:5)
您无法使用selenium运行事务,因为测试在应用程序AFAIK的两个单独实例上运行