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.
I think that's the best way for now.
I filed a bug/feature-request for this about two months back. You might want to comment there and add a vote of support if it's something that would make things easier for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With