javascript alert .press 'Ok' with capybara and cucumber test case javascript alert .press 'Ok' with capybara and cucumber test case selenium selenium

javascript alert .press 'Ok' with capybara and cucumber test case


Get a reference to the alert using the following:

alert = page.driver.browser.switch_to.alert

And then

alert.accept

To hit 'Ok'


Jon's didn't work for me probably because I'm using a newer version of capybara (2.1.0)

This worked for me:

page.evaluate_script('window.confirm = function() { return true; }')