Using Se开发者_开发知识库lenium 2.0 After Submitting a web form, A popup msg comes up with the "are you sure you want to navigate away from this page" message, How do I get selenium to press OK or disable this popup?
I have already tried
Alert alert = driver.switchTo().alert();
alert.accept();
or
alert.dismiss();
edit:
quick fix, I just overwrote the popup function using JS
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("window.onbeforeunload = function() {};");
form.submit();
this will stop will disable this popup, the same can be done for js alerts, comfirm and prompt boxes
See if this answer helps:
http://code.google.com/p/selenium/issues/detail?id=27#c6
Overall, the thread raises a similar concern as yours. You are trying to handle this as an alert, see if you can handle this as a js confirmation dialog.
精彩评论