黄瓜 + 硒随机失败
我的硒测试喜欢随机失败。 作为一个例子,我有这样的场景
Scenario: I should be able to edit a user
Given I created a user with the login "[email protected]"
And I am viewing the user with login "[email protected]"
Then I should see "Edit this user"
When I click "Edit this user"
Then I should be editing the user with login "[email protected]"
When I press "Update"
Then I should be viewing the user with login "[email protected]"
And I should see "User was successfully updated."
,与其他场景一起,使用基本的 webrat :rails 模式可以很好地工作。 在硒中,线路
Then I should be editing the user with login "[email protected]"
和
Then I should be viewing the user with login "[email protected]"
失败是随机的,因为有时第一个失败,有时第二个失败。 手动使用该网站会导致正确的操作,并且正如我所说,webrat/rails 模式工作正常。
导轨2.2.2 黄瓜0.3.7 selenium 1.1.14(已修复以与 FF3 一起使用)
一些额外信息:
Scenario: I should be able to edit a user # features/admin_priviledges.feature:26
Given I created a user with the login "[email protected]" # features/step_definitions/global_steps.rb:18
And I am viewing the user with login "[email protected]" # features/step_definitions/global_steps.rb:60
Then I should see "Edit this user" # features/step_definitions/webrat_steps.rb:93
When I click "Edit this user" # features/step_definitions/webrat_steps.rb:18
Then I should be editing the user with login "[email protected]" # features/step_definitions/global_steps.rb:66
expected: "/users/8/edit",
got: "/users/8" (using ==)
Diff:
@@ -1,2 +1,2 @@
-/users/8/edit
+/users/8
(Spec::Expectations::ExpectationNotMetError)
features/admin_priviledges.feature:31:in `Then I should be editing the user with login "[email protected]"'
When I press "Update" # features/step_definitions/webrat_steps.rb:14
Then I should be viewing the user with login "[email protected]" # features/step_definitions/global_steps.rb:66
And I should see "User was successfully updated."
Then /^I should be (editing|viewing) the (\w+) with (\w+) "([^\"]*)"$/ do |action,model,field,value|
func = make_func(action,model)
m = find_model_by_field_and_value(model,field,value)
URI.parse(current_url).path.should == eval("#{func}(m)")
end
这些是相关步骤。 按“更新”按钮是标准的 webrat 步骤(click_button)
My selenium tests like to fails randomly. As an example I have this scenario
Scenario: I should be able to edit a user
Given I created a user with the login "[email protected]"
And I am viewing the user with login "[email protected]"
Then I should see "Edit this user"
When I click "Edit this user"
Then I should be editing the user with login "[email protected]"
When I press "Update"
Then I should be viewing the user with login "[email protected]"
And I should see "User was successfully updated."
This, along with the others, work fine using the basic webrat :rails mode. In selenium, the line
Then I should be editing the user with login "[email protected]"
and
Then I should be viewing the user with login "[email protected]"
fail randomly, in that sometimes the first fails, other times the seconds fails. Using the website by hand results in the correct operation, and like I said, the webrat/rails mode works fine.
Rails 2.2.2
Cucumber 0.3.7
selenium 1.1.14 (fixed to work with FF3)
Some extra info:
Scenario: I should be able to edit a user # features/admin_priviledges.feature:26
Given I created a user with the login "[email protected]" # features/step_definitions/global_steps.rb:18
And I am viewing the user with login "[email protected]" # features/step_definitions/global_steps.rb:60
Then I should see "Edit this user" # features/step_definitions/webrat_steps.rb:93
When I click "Edit this user" # features/step_definitions/webrat_steps.rb:18
Then I should be editing the user with login "[email protected]" # features/step_definitions/global_steps.rb:66
expected: "/users/8/edit",
got: "/users/8" (using ==)
Diff:
@@ -1,2 +1,2 @@
-/users/8/edit
+/users/8
(Spec::Expectations::ExpectationNotMetError)
features/admin_priviledges.feature:31:in `Then I should be editing the user with login "[email protected]"'
When I press "Update" # features/step_definitions/webrat_steps.rb:14
Then I should be viewing the user with login "[email protected]" # features/step_definitions/global_steps.rb:66
And I should see "User was successfully updated."
Then /^I should be (editing|viewing) the (\w+) with (\w+) "([^\"]*)"$/ do |action,model,field,value|
func = make_func(action,model)
m = find_model_by_field_and_value(model,field,value)
URI.parse(current_url).path.should == eval("#{func}(m)")
end
Those are the relevant steps. The press "Update" one is a standard webrat step (click_button)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将 webrat 步骤从 更改
为
有效。 告诉 Selenium 等待修复!
Changing a webrat step from
to
it works. Telling selenium to wait fixes!
您是否看过请求的时间? 我的直觉告诉我,硒的发展速度太快了。
您可以发布您的黄瓜步骤以及每次失败的错误消息和日志详细信息吗?
Have you looked at the timing of the requests? My gut says it is that selenium is moving too fast.
Can you post your cucumber steps and the error messages and log details for each failure?