How do I confirm a javascript popup with Capybara?
capybara, ruby-on-rails, testing
Solution
Adding an answer for those hitting this in 2016 and beyond. You can now use Capybara directly to accept a confirmation box. You do this by wrapping the code that causes the confirmation box to appear in the accept_confirm function.
accept_confirm do
click_link 'Destroy'
end
Problem
I've tried several examples found online, but with no luck. I am looking to confirm the confirm message of a delete link. The last attempt was the code below, but that resulted in an Capybara::NotSupportedByDriverError error. ``` def confirm_dialog page.evaluate_script('window.confirm = function() { return true; }') end ```