代码之家  ›  专栏  ›  技术社区  ›  Eduardo León

黄瓜+硒随机失效

  •  5
  • Eduardo León  · 技术社区  · 17 年前

    Scenario: I should be able to edit a user
      Given I created a user with the login "test@example.com"
      And I am viewing the user with login "test@example.com"
      Then I should see "Edit this user"
      When I click "Edit this user"
      Then I should be editing the user with login "test@example.com"
      When I press "Update"
      Then I should be viewing the user with login "test@example.com"
      And I should see "User was successfully updated."
    

    Then I should be editing the user with login "test@example.com"
    

    Then I should be viewing the user with login "test@example.com"
    

    随机失败,有时第一个失败,有时第二个失败。手动使用网站会导致正确的操作,就像我说的,webrat/rails模式运行良好。

    钢轨2.2.2 黄瓜0.3.7

    Scenario: I should be able to edit a user                         # features/admin_priviledges.feature:26
      Given I created a user with the login "test@example.com"        # features/step_definitions/global_steps.rb:18
      And I am viewing the user with login "test@example.com"         # 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 "test@example.com" # 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 "test@example.com"'
      When I press "Update"                                           # features/step_definitions/webrat_steps.rb:14
      Then I should be viewing the user with login "test@example.com" # 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
    

    2 回复  |  直到 17 年前
        1
  •  7
  •   Eduardo León    17 年前

    更改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
    

    它奏效了。告诉硒等待修复!

        2
  •  2
  •   srboisvert    17 年前

    你能发布你的黄瓜步骤、错误消息和每次失败的日志详细信息吗?