これはRspec機能です。Capybara/RspecがSweet Alert Modalでボタンを見つけることができないのにhas_selectorがtrueを返すのはなぜですか?
given (:send_selector){ 'button.confirm'}
feature "when talent has not applied." do
given (:apply_button) { find('button[data-selector="offer-apply-button"]') }
before(:each) { visit offer_path(offer.id) }
scenario "Talent applies to offer with default cv", js: true do
apply_button.click
expect(page).to have_selector(send_selector)
find_button(send_selector).click
wait_for_ajax
# other expectations
end
end
これはセレクタを有することが期待を通過するが、それは私もまだpage.find_button(send_selector).click
とfind_button(send_selector).trigger('click')
を使用して試みたが、最初のfind_button(send_selector).click
有する線に指向誤差
Capybara::ElementNotFound:
Unable to find button "button.confirm"
をスローエラーをスローし、次のliでスクリーンショットをとると、アクションを担当するコントローラが呼び出されず、モーダルがまだ残っているため、2番目のものは何もしないようですne。
私はpoltergeistデバッガを実行し、そのページにはhtmlがあります。
カピバラから見たように、これは(save_screenshot()
メソッドを使用して)モーダルで
こんにちはトーマス、あなたは正しい、find_buttonはcssセレクタを取らない。それでも、私はこの時間に「スリープ1」なしで投稿したテストを実行し、失敗しました。 – juliangonzalez
@juliangonzalez同じエラーの場合は、おそらくCapybara.default_max_wait_timeを数秒増やす必要があることを意味します。しかし、別のエラー(マウスクリックに関する何かが別の要素に当たった場合)は、モーダルがまだアニメーション化されているので、テストモードでアニメーションを無効にするかスリープ状態にする必要があります。多少の傷みを防ぐ –