Dealing with Javascript alert from browser with Capybara
Today while working on an automation script I came across this error, it’s basically a Javascript alert from the browser.
Modal dialog present (Selenium::WebDriver::Error::UnhandledAlertError)
A quick way to automate this if you are using Capybara, execute this command in your step definitions:
To accept the alert:
page.driver.browser.switch_to.alert.accept
To dismiss the alert:
page.driver.browser.switch_to.alert.dismiss
Tags: browser, capybara, error, Javascript, Selenium
Originally published at www.farooqyousuf.net.