禁用 python chrome 驱动程序扩展,而不会丢失驱动程序路径



我开始遇到运行使用硒和铬驱动程序的 python 脚本的问题,所以我想使用 python 禁用 chrome 驱动程序的扩展,而不会丢失驱动程序所在的路径。

目前我有以下内容:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
path_to_Ie = 'C:\Python34\ChromeDriver\ChromeDriver.exe' 
browser = webdriver.Chrome(executable_path = path_to_Ie)
url = 'https://wwww.test.com/'
browser.get(url)

我想添加以下几行:

chrome_options = Options()
chrome_options.add_argument("--disable-extensions")
browser = webdriver.Chrome(chrome_options=chrome_options)

知道如何合并两个代码以使其正常工作吗?

多谢。

只需提供多个关键字参数:

chrome_options = Options()
chrome_options.add_argument("--disable-extensions")
browser = webdriver.Chrome(executable_path=path_to_Ie, chrome_options=chrome_options)

相关内容

最新更新