私はキュウバー& Capybaraを統合テストに使用していました。サイトではjavascriptが多く使用されているため、javascriptドライバとしてセレンを使用する環境を設定しました。しかし、それは私がそこにいるはずの要素で失敗し続けているようだ。何か不足していますか?ここでCapybara/Selenium Capybara :: 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"
ここで私は、私はそれがうまく渡す使用する他のテストとしてGiven I am logged in
作品を、知っている要素
When /^(?:|I)click element "([^"]*)"$/ do |id|
find(id).click
end
をクリックするためのステップの定義です。なぜ#enter-combatが見つからないのでしょうか?私が物理的に自分自身にログインするとき、私はそれがちょうどうまく見ることができます。
編集:他のステップ定義が追加されました。
(::)失敗したステップを(:
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
に私は要素をクリックし、 "#戦闘入力して"」
編集
を210私は今、既定の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