本文介紹了如何使用 Python 將選項傳遞給 Selenium Chrome 驅動程序?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
Selenium 文檔 提到 Chrome 網絡驅動程序可以采用 ChromeOptions
的實例,但我不知道如何創建 ChromeOptions
.
The Selenium documentation mentions that the Chrome webdriver can take an instance of ChromeOptions
, but I can't figure out how to create ChromeOptions
.
我希望將 --disable-extensions
標志傳遞給 Chrome.
I'm hoping to pass the --disable-extensions
flag to Chrome.
推薦答案
找到了Selenium 源代碼中的chrome Options 類.
用于創建Chrome驅動實例:
Usage to create a Chrome driver instance:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--disable-extensions")
driver = webdriver.Chrome(chrome_options=chrome_options)
這篇關于如何使用 Python 將選項傳遞給 Selenium Chrome 驅動程序?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!