오이 + 셀레늄은 무작위로 실패합니다
-
12-09-2019 - |
문제
내 셀레늄 테스트는 무작위로 실패하는 것을 좋아합니다. 예를 들어이 시나리오가 있습니다
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."
이것은 다른 사람들과 함께 기본 Webrat : Rails 모드를 사용하여 잘 작동합니다. 셀레늄에서 라인
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 모드는 제대로 작동합니다.
Rails 2.2.2 Cucumber 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 "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
그것들은 관련 단계입니다. 프레스 "업데이트"는 표준 Webrat 단계입니다 (Click_Button)
해결책
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
효과가있다. 셀레늄에게 수정 대기를 기다리라고!
다른 팁
요청시기를 살펴 보셨습니까? 내 직감은 셀레늄이 너무 빨리 움직이고 있다고 말합니다.
오이 단계와 각 오류에 대한 오류 메시지 및 로그 세부 사항을 게시 할 수 있습니까?
제휴하지 않습니다 StackOverflow