简体   繁体   English

如何关闭弹出通知? 使用 selenium python 进行自动化测试

[英]How to dismiss popup notification? For automation testing using selenium python

My task is to login facebook and to go on main page.我的任务是登录 facebook 并进入主页。 After my code enters facebook it shows this notification and my code crashes.在我的代码进入 facebook 后,它会显示此通知并且我的代码崩溃了。 How can I disable this so that code continues working?如何禁用它以便代码继续工作?

I'm new in Python Thanks in advance.我是 Python 新手提前致谢。

Image of the error: Popup error错误图像:弹出错误

ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-notifications");

or in python, that would be或者在 python 中,那就是

chrome_options = webdriver.ChromeOptions()
prefs = {"profile.default_content_setting_values.notifications" : 2}
chrome_options.add_experimental_option("prefs", prefs)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM