Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如何告诉capybara webkit不要忽略确认框(或只是测试其内容)_Ruby On Rails_Ruby On Rails 3_Cucumber_Capybara_Capybara Webkit - Fatal编程技术网

Ruby on rails 如何告诉capybara webkit不要忽略确认框(或只是测试其内容)

Ruby on rails 如何告诉capybara webkit不要忽略确认框(或只是测试其内容),ruby-on-rails,ruby-on-rails-3,cucumber,capybara,capybara-webkit,Ruby On Rails,Ruby On Rails 3,Cucumber,Capybara,Capybara Webkit,所以我有一个场景: Given I signed in to my business account And there is one customer named "Samantha Seeley" When I go to the customers management page Then "Delete" should show a confirmation dialog saying "Are you sure?" 链接很简单: <%= link_to 'Delete' cus

所以我有一个场景:

Given I signed in to my business account
And there is one customer named "Samantha Seeley"
When I go to the customers management page
Then "Delete" should show a confirmation dialog saying "Are you sure?"
链接很简单:

<%= link_to 'Delete' customer_path(customer), method: :delete, confirm: 'Are you sure?' do %>
我相信我可以从截图上确认javascript似乎没有被评估(没有显示确认对话框)。这个假设可能是错误的,但我不确定


感谢您的帮助。

GitHub上也出现了类似的问题:

结论是使用类似的方法,这是由和提出的:

这不会帮助您测试确认对话框的内容(尽管可以很容易地进行扩展),但它允许您测试用户单击确定或取消时发生的情况


在这种特定情况下,您需要一个确认对话框,因为您使用的是一个生成对话框的Rails助手。值得考虑的是,这是否需要在您自己的应用程序中进行测试覆盖;已经有了。

真棒的人,非常感谢。在这件事上花了太多时间。
Then /^"(.*?)" should show a confirmation dialog saying "(.*?)"$/ do |arg1, arg2|
  click_on arg1
  page.driver.render "tmp/screenshot.jpg"
end
def handle_js_confirm(accept=true)
  page.evaluate_script "window.original_confirm_function = window.confirm"
  page.evaluate_script "window.confirm = function(msg) { return #{!!accept}; }"
  yield
ensure
  page.evaluate_script "window.confirm = window.original_confirm_function"
end