How to check if JavaScript alert is present (or not present) in a Capybara session?

740 views Asked by At

I'm trying to write a test that confirms that no JavaScript alert is present on the page (because in capybara-webkit, it is silencing this alert, but in selenium it correctly raises an error). How can I write a test to expect(page).to_not have_alert?

1

There are 1 answers

2
Joe Ferris On BEST ANSWER

This behavior will be changing in capybara-webkit 2.0 to follow the example set by Selenium.

In the mean time, you can check page.driver.alert_messages to make sure no alerts have been opened.