处理“您确定您想要离开这个页面”Msg在Selenium 2.0。
Using Selenium 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?
在提交web表单后使用Selenium 2.0,弹出的msg会出现“您确定要离开这个页面吗”的消息,我如何让Selenium按OK或禁用这个弹出窗口?
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
快速修复,我只是用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
这将停止将禁用此弹出,同样可以对js警报、comfirm和提示框执行此操作
1 个解决方案
#1
3
See if this answer helps:
http://code.google.com/p/selenium/issues/detail?id=27#c6
看看这个答案是否有用: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.
总的来说,这条线引发了与你类似的担忧。您试图将其作为警报处理,看看是否可以将其作为js确认对话框处理。