我一直在使用黃瓜&水豚進行集成測試。由於該網站使用了大量的JavaScript,我將環境設置爲使用硒作爲JavaScript驅動程序。然而,它似乎仍然在我認爲應該在那裏的元素失敗。有什麼我失蹤?水豚/硒水豚:: ElementNotFound - 當運行@javascript
這裏的特點:
Feature: Combat
In order to engage in combat
As a registered user
I want to be able to kill enemy ships
@javascript
Scenario: Initialize combat
Given I am logged in
# When I go to the homepage
When I click element "#enter-combat"
Then the page should contain a section with the class "map"
下面是當我點擊元素
When /^(?:|I)click element "([^"]*)"$/ do |id|
find(id).click
end
我知道Given I am logged in
作品,使用它的其他測試通過精細的步驟定義。關於爲什麼#進入戰鬥的任何想法都找不到?當我親自登錄時,我可以看到它很好。
編輯:添加了其他步驟定義。
Given /^I am logged in$/ do
email = '[email protected]'
password = 'demonic'
steps %Q{
Given the following user exists:
| first_name | last_name | email | password | password_confirmation |
| Murray | Skull | #{email} | #{password} | #{password} |
And I login as "#{email}" with the password "#{password}"
}
end
Given /^I login as "([^\"]*)" with the password "([^\"]*)"$/ do |email, password|
steps %Q{
Given I am not logged in
When I go to the login page
And I fill in "user_email" with "#{email}"
And I fill in "user_password" with "#{password}"
And I press "Login"
}
end
這裏是當我運行的輸出:
(::)失敗的步驟(::)
無法找到 '#進入戰鬥'(水豚:: ElementNotFound) ./功能/ step_definitions/combat_steps.rb:6:/^(?:|I)click element "([^"]*)"$/' features/combat/combat.feature:9:in
當我點擊元素 「#進入戰鬥」」
編輯
現在我使用的是默認的Web步驟之一:我按「回車戰鬥」,所以我的功能現在是:
Feature: Initialize Combat
In order to engage in combat
As a registered user
I want to be able to initialize it
@javascript
Scenario: Initialize combat
Given I am logged in
When I go to the homepage
And I press "enter-combat"
Then the page should contain a section with the class "map"
還是同樣的錯誤
你可以給出運行場景的輸出嗎? – efoo
也可以提供'鑑於我已登錄'步驟定義完成# – iafonov
。多謝你們。 – agmcleod