如何从浏览器中删除通知和警报?硒python 2.7.7 [英] how can i remove notifications and alerts from browser? selenium python 2.7.7
问题描述
我正在尝试在网页中提交信息,但是selenium引发此错误:
I am trying to submit information in a webpage, but selenium throws this error:
UnexpectedAlertPresentException:警报文本:此页面询问您 确认您要离开-您输入的数据可能不会 已保存. , >
UnexpectedAlertPresentException: Alert Text: This page is asking you to confirm that you want to leave - data you have entered may not be saved. , >
这不是请假通知;这是通知的图片-
It's not a leave notification; here is a pic of the notification -
.
如果单击从不再次显示此通知",则不会保存我的操作;有没有办法保存它或禁用所有通知?
If I click in never show this notification again, my action doesn't get saved; is there a way to save it or disable all notifications?
编辑:我正在使用Firefox.
edit: I'm using firefox.
推荐答案
您可以使用chrome选项禁用浏览器通知.下面的示例代码:
You can disable the browser notifications, using chrome options. Sample code below:
chrome_options = webdriver.ChromeOptions()
prefs = {"profile.default_content_setting_values.notifications" : 2}
chrome_options.add_experimental_option("prefs",prefs)
driver = webdriver.Chrome(chrome_options=chrome_options)
这篇关于如何从浏览器中删除通知和警报?硒python 2.7.7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!