selenium如何屏蔽谷歌瀏覽器彈出的通知


使用selenium訪問新浪微博的時候  瀏覽器總會有個通知,需要點擊  類似下面這樣

 

 

下面使用chromeoptions來修改瀏覽器的設置

 

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(chrome_options = options)

driver =webdriver.Chrome()
driver.get("https://weibo.com/")
driver.implicitly_wait(10)
time.sleep(2)

---------------------
原文:https://blog.csdn.net/andydufre/article/details/79204158


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM