Pepino + selénio falhar aleatoriamente
-
12-09-2019 - |
Pergunta
Os meus testes de selênio como a falha aleatoriamente. Como um exemplo, eu tenho este cenário
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."
Isto, junto com os outros, funcionam bem usando o webrat básica: modo de trilhos. Em selênio, a linha
Then I should be editing the user with login "test@example.com"
e
Then I should be viewing the user with login "test@example.com"
falhar aleatoriamente, em que às vezes o primeiro falhar, outras vezes os segundos falha. Usando o site por resultados mão na operação correta, e como eu disse, o webrat / modo de trilhos bem funciona.
Rails 2.2.2 pepino 0.3.7 selênio 1.1.14 (fixo para trabalhar com FF3)
Algumas informações adicionais:
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
Esses são os passos relevantes. A imprensa "Update" é um passo webrat padrão (click_button)
Solução
Alterar um passo webrat de
When /^I press "([^\"]*)"$/ do |button|
click_button(button)
end
para
When /^I press "([^\"]*)"$/ do |button|
click_button(button)
selenium.wait_for_page_to_load
end
ele funciona. Dizendo selênio para esperar correções!
Outras dicas
Você olhou para o calendário dos pedidos? Meu instinto diz que é que o selênio está se movendo muito rápido.
Você pode postar seus passos de pepino e as mensagens de erro e os detalhes de log para cada falha?