2009-06-08 17 views
4

셀렌 테스트가 무작위로 실패하는 것과 같습니다. 예를 들어 나는이 시나리오를 가지고있다.오이 + 셀레늄이 무작위로 실패합니다.

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 셀레늄 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: "https://stackoverflow.com/users/8/edit", 
     got: "https://stackoverflow.com/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)

답변

7

작동

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

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

에서 webrat 스텝을 변경합니다. 셀레늄이 수정을 기다리라고 말하고 있습니다!

2

요청한시기를 보았습니까? 내 직감은 셀레늄이 너무 빨리 움직이고 있다고 말한다.

오이 단계와 오류 메시지 및 각 실패에 대한 세부 정보를 게시 할 수 있습니까?

+0

몇 가지 추가 정보. Webrat.configure 블록에서 셀레늄의 속도를 설정할 수 있습니까? –

+0

그것에 대한 해결책은 무엇입니까? 같은 문제가있는 것 같습니다. –