Handle notifications in Python + Selenium Chrome W

2019-01-15 16:35发布

How can Selenium Chrome WebDriver notifications be handled in Python?

Have tried to dismiss/accept alert and active element but seems notifications have to be treated other way. Also, all the Google search results are driving me to Java solution which I do not really need. I'm a newbie in Python.

Thanks in advance.

enter image description here

1条回答
Fickle 薄情
2楼-- · 2019-01-15 17:20

You can disable the browser notifications, using chrome options.

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)
查看更多
登录 后发表回答