を使用した標準的なキュウリ統合テスト スタックがあります。
- Ruby v.1.9.3、
- レール v.3.2.13
- カピバラ v.2.1.0
- Capybara-Webkit v.1.0.0
- FactoryGirl v.4.2.1
最近、複数の連続する ajax リクエストを含む一連のシナリオが散発的に失敗し、次のエラーが発生するという問題が発生しました。
Capybara::Webkit::NodeNotAttachedError (Capybara::Webkit::NodeNotAttachedError)
./features/step_definitions/patient_steps.rb:133:in `/^I should see the followin
g patient names in this order:$/'
features\searching_patients_index.feature:39:in `Then I should see the following
patient names in this order:'
興味深いのは、このエラーが Windows マシンでのみスローされることです。
この問題に対する最も典型的な対応は次のとおりです。
ある種の sleep または wait_until を強制します (非推奨であるにもかかわらず、Capybara v.1.1.3 に戻して試してみました) が、これは役に立ちませんでした。
デフォルトのカピバラの待ち時間を増やしてみました
DOM の特定の部分が表示されるかどうかを確認することで、「 _が表示されるまで待機」を試みました。
When(/^I wait until "(.*?)" is visible$/) do |selector| page.has_css?("#{selector}", :visible => true) end
失敗した機能の 1 つの例を次に示します。
Scenario: Searching and then sorting patients
When I search for "J"
And I click on the "Name" header in the "patients" table
And I wait until ".patient.odd" is visible
Then I should see the following patient names in this order:
| names |
| Smith, John |
| Schmo, Jill |
Then the result content should not include "Drapper, Don"
テーブルの検索と列による並べ替えの両方に Ajax を使用しているため、この例では、並べ替え時に検索が持続するかどうかをテストしています。
さらに詳しい状況を提供できる場合はお知らせください。ご協力いただきありがとうございます。