python+selenium处理chrom显示通知弹框
Posted vigogogogo
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python+selenium处理chrom显示通知弹框相关的知识,希望对你有一定的参考价值。
使用chrome打开weibo.com会出现以下界面的弹出框:
这东西不属于页面alert弹框,而是属于浏览器的设置项。
要关掉它,需要对浏览器进行属于配置。具体见下面脚本:
from selenium import webdriver import time options = webdriver.ChromeOptions() prefs = { ‘profile.default_content_setting_values‘:{ ‘notifications‘:2 } } options.add_experimental_option(‘prefs‘,prefs) driver = webdriver.Chrome(options = options) driver.get("https://weibo.com/") driver.implicitly_wait(10)
以上是关于python+selenium处理chrom显示通知弹框的主要内容,如果未能解决你的问题,请参考以下文章