2016-10-25 3 views
-1

次のページが読み込まれるのを待つ方法。送信ボタン(基本登録フロー)をクリックすると、テストケースが失敗し、要素を見つけることができません。私は初めてキュウリとカピバラを使って、これに新しいです。キュウリとカピバラ:次のページが読み込まれるのを待つ方法。送信ボタンをクリックすると、テストケースが失敗し、要素を見つけることができません。

私はデフォルトの待ち時間で10秒を与えました。カピバラを使用して明示的にその要素を待つ方法はありますか?

エラー:

Scenario: Register with valid credentials         # features/Job_seeker_Registration.feature:6 
    Given I am on "/register"            # features/step_definitions/web_steps.rb:2 
Unable to find field "#jobseekerName" 
    When I have entered "Seeker1" into the "jobseekerName" field    # features/step_definitions/web_steps.rb:6 
Unable to find field "#jobseekerMobileOrEmail" 
    When I have entered "7812125899" into the "jobseekerMobileOrEmail" field # features/step_definitions/web_steps.rb:6 
    Then I wait for 1 seconds            # features/step_definitions/web_steps.rb:33 
    When I pick "Driver" from "field-desiredcategory"      # features/step_definitions/web_steps.rb:16 
Unable to find field "#jobseekerPassword" 
    When I have entered "4679" into the "jobseekerPassword" field   # features/step_definitions/web_steps.rb:6 
    And I click on "jobSeekerRegister"          # features/step_definitions/web_steps.rb:11 
    Then I wait for 40 seconds            # features/step_definitions/web_steps.rb:33 
    Then I should see "verificationButton"         # features/step_definitions/web_steps.rb:25 
     expected to find text "verificationButton" in "SEARCH JOBS SEARCH CANDIDATES LOOKING TO HIRE? (RSpec::Expectations::ExpectationNotMetError) 
     features/Job_seeker_Registration.feature:15:in `Then I should see "verificationButton"' 
    And I click on "Seeker 1"            # features/step_definitions/web_steps.rb:11 
    And I click on "Edit my Profile"           # features/step_definitions/web_steps.rb:11 
    Then I wait for 1 seconds            # features/step_definitions/web_steps.rb:33 
    HTML screenshot: ./screenshot/screenshot.html 
    Image screenshot: ./screenshot/screenshot.png 

Failing Scenarios: 
cucumber features/Job_seeker_Registration.feature:6 # Scenario: Register with valid credentials 

1 scenario (1 failed) 
12 steps (1 failed, 3 skipped, 8 passed) 
0m55.271s 

コード:おそらくあなたは要素の存在をテストしている方法を調整する必要が

Then /^I should see "(.*?)"$/ do |text| 
    page.should have_content(text) 
end 
Then /^I should see title "(.*?)"$/ do |text| 
    page.should have_title?(text) 
end 
Given /^I wait for (\d+) seconds?$/ do |n| 
    sleep(n.to_i) 
end 
+0

エラーの原因となっているエラーメッセージとコードを表示してください。 – Stefan

+0

エラーを追加しました。 – AmarV

+0

そして今、対応するコードをしてください。 – Stefan

答えて

0

。正しく実行している場合、Capybaraは要素が表示されるまで待機します。例えば

# this noes not wait until the element exists 
first(".active").click 

いますが、これについてのより多くの例を与えるa great articleを持ってThoughtbot

# this this waits until an element with the class "active" is found 
find(".active").click  

を見つけ使用している場合。

関連する問題