I am trying to dismiss "Confirm Navigation" popup. This is how it looks like in Chrome.
To see the popup:
require "watir-webdriver"
browser = Watir::Browser.new
browser.goto "http://www.gravityforms.com/demo/wp-admin/admin.php?page=gf_new_form"
browser.text_field(:id => "user_login").set "demo"
browser.text_field(:id => "user_pass").set "demo"
browser.button(:id => "wp-submit").click
browser.refresh
At the moment I override onbeforeunload
when I visit the page, as suggested at http://watirwebdriver.com/javascript-dialogs/
browser.execute_script("window.onbeforeunload = function() {};")
So, the script now looks like this:
require "watir-webdriver"
browser = Watir::Browser.new
browser.goto "http://www.gravityforms.com/demo/wp-admin/admin.php?page=gf_new_form"
browser.text_field(:id => "user_login").set "demo"
browser.text_field(:id => "user_pass").set "demo"
browser.button(:id => "wp-submit").click
browser.execute_script("window.onbeforeunload = function() {};")
browser.refresh
And it works just fine. I am just wondering if there is a better solution.