黄瓜 + 硒随机失败

发布于 2024-07-23 18:34:19 字数 3790 浏览 8 评论 0原文

我的硒测试喜欢随机失败。 作为一个例子,我有这样的场景

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

南城旧梦 2024-07-30 18:34:19

将 webrat 步骤从 更改

When /^I press "([^\"]*)"$/ do |button|
  click_button(button)
end

When /^I press "([^\"]*)"$/ do |button|
  click_button(button)
  selenium.wait_for_page_to_load
end

有效。 告诉 Selenium 等待修复!

Changing a webrat step from

When /^I press "([^\"]*)"$/ do |button|
  click_button(button)
end

to

When /^I press "([^\"]*)"$/ do |button|
  click_button(button)
  selenium.wait_for_page_to_load
end

it works. Telling selenium to wait fixes!

各自安好 2024-07-30 18:34:19

您是否看过请求的时间? 我的直觉告诉我,硒的发展速度太快了。

您可以发布您的黄瓜步骤以及每次失败的错误消息和日志详细信息吗?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文