After completing one scenario, the page automatically refreshes. A JavaScript modal is displayed on the website asking the user "Are you sure you want to leave the page?" I need to confirm that modal, but every time I try to create a step for it, I encounter the following error:
Then User clicks "Leave this page" button in the popup at online reg form
no alert open
(Session info: chrome=35.0.1916.114)
Here is the code snippet:
And(/^User clicks "([^"]*)" button in the popup at online reg form$/) do |button|
wait = Selenium::WebDriver::Wait.new
alert = wait.until { page.driver.browser.switch_to.alert }
alert.accept
end
I am seeking assistance on how to resolve this issue. Any suggestions?