私はレールテストでsweetalertポップアップをクリックしようとしていますが、ボタンが見つからないことを教えてくれます。私のコードは次のようになります。SweetAlert2テスト中にクリックすると確認します
it "should delete dummy user", js: true do
user = FactoryGirl.create(:user)
login user
FactoryGirl.create(:course, :with_user_created)
dummy_user = FactoryGirl.create(:dummy_user)
visit booking_index_path("en")
current_path.should eq(booking_index_path("en"))
page.should have_content(dummy_user.name)
page.find("#delete_dummy_" + dummy_user.id.to_s).trigger("click")
click_button "Yes"
page.should have_no_content(dummy_user.name)
end
そして、私はエラーを取得しています:
Capybara::ElementNotFound:
Unable to find button "Yes"
私はそうのようなsweetalertを呼んでいる:カピバラは見つけることができない理由
var modal_open = false;
$(document).ready(function() {
$(".alert-sweet").on('click', function(e){
if (modal_open){
modal_open = false;
return true;
}
e.preventDefault();
link = $(this);
swal({
title: "<%= t("you_sure") %>",
confirmButtonText: "<%= t("t_yes") %>",
cancelButtonText: "<%= t("t_no") %>",
type: "warning",
showCancelButton : true,
confirmButtonColor : "#DD6B55",
closeOnConfirm : false
}).then(function() {
modal_open = true;
link.trigger('click');
}, function(dismiss) {
if (dismiss === 'cancel') {
modal_open = false;
}
});
return false;
});
});
任意のアイデアボタン?私はクリックして「#delete_dummy_」+ dummy_user.id.to_s後に穴のページを印刷しようとしました」と、ボタンがあるようです:
...
<div class="swal2-container">
<div class="swal2-overlay" tabindex="-1"></div>
<div class="swal2-modal" style="display: none; width: 500px; padding: 20px; margin-left: -250px; background-color: rgb(255, 255, 255); background-position: initial initial; background-repeat: initial initial;" tabindex="-1">
<div class="swal2-icon swal2-error" style="display: none;">
<span class="x-mark">
<span class="line left"></span>
<span class="line right"></span>
</span>
</div>
<div class="swal2-icon swal2-question" style="display: none;">?</div>
<div class="swal2-icon swal2-warning pulse-warning" style="display: block;">!</div>
<div class="swal2-icon swal2-info" style="display: none;">i</div>
<div class="swal2-icon swal2-success" style="display: none;">
<span class="line tip"></span>
<span class="line long"></span>
<div class="placeholder"></div>
<div class="fix"></div>
</div>
<img class="swal2-image" style="display: none;">
<h2>Are you sure?</h2>
<div class="swal2-content" style="display: none;"></div>
<input class="swal2-input">
<select class="swal2-select"></select>
<div class="swal2-radio"></div>
<label for="swal2-checkbox" class="swal2-checkbox">
<input type="checkbox" id="swal2-checkbox"></label>
<textarea class="swal2-textarea"></textarea>
<div class="swal2-validationerror"></div>
<hr class="swal2-spacer" style="display: block;">
<button class="swal2-confirm styled" style="background-color: rgb(221, 107, 85);">Yes</button>
<button class="swal2-cancel styled" style="display: inline-block; background-color: rgb(170, 170, 170);">No</button>
<span class="swal2-close" style="display: none;">×</span>
</div>
</div>
はEDIT:
が問題のように見えます。。?sweetalertが表示されていないので、私はすでにアニメーションを無効になっていますが、それでも、それはクリックする任意の提案に目に見えるそれを回していない
delete_dummy _...要素をクリックしてスクリーンショットを保存し、実際に何がページ上にあるのかを見てみましょう - current_pathで 'eq'マッチャーを使用してはいけません。 '' page.should have_current_path(booking_index_path( "en")) ' –
sweetalertプロジェクトのページを見ると、swalが約束を返す場所は何も言われていないので、あなたのpoltergeistドライバの設定に 'js_errors:false'が設定されているので、あなたのページにJSエラーが隠れているのですか? –