在Web應用程序中,我使用jQueryUI的模式對話框來確認操作:如何模擬與水豚的jQuery-UI模式對話框按鈕的點擊?
function erase() {
$("#dialog").text("Are you sure want to delete this record?")
.attr("title", "Delete...")
.dialog({
modal: true,
buttons: {
Delete: function() {
$.ajax({
...snip...
success: function() {
self.location = "."; // returns to the welcome page
}
});
},
...snip...
}
});
}
代碼工作得很好,但我不能與水豚測試它成功:
...snip...
Capybara.default_driver = :webkit
...snip...
def in_dialog()
f = find('.ui-dialog')
end
feature 'Delete a record' do
...snip...
scenario 'for any record' do
click_on 'Delete...'
page.should have_content 'Are you sure want to delete this record?'
in_dialog.click_button 'Delete'
page.should have_content 'Welcome'
...snip...
end
end
水豚發現按鈕,但一切都好像回調從未被解僱。
我嘗試了不同的解決方法(其中有幾個我計算器上找到):
- 睡眠,
- 「等AJAX」
- page.native.send_keys(:收益),而不是click_button 'Delete',
- find('button',:text =>'Delete')。click代替click_button'Delete',
- Selenium驅動代替webkit驅動。
無效。任何其他想法?
你可以發表一個複製案例(如果它對於SO來說很大,那麼對於例如gist.github.com)? –
以下是與我的測試服務器交互的水豚場景的要點:https://gist.github.com/4547091 –
請準備包括相關HTML/JS文件的複製案例。如果我不知道如何重現問題,你如何指望我們告訴如何解決問題? –