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

标签 python selenium

我开始在运行使用 selenium 和 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)

关于python - 禁用 python chrome 驱动程序扩展而不丢失驱动程序路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38226305/

相关文章:

cookies - 使用 Selenium IDE 清除 session cookie?

python - 在 python 中将列表分解为重叠的元组列表

python - 到/来自列表的字典的字典列表

Python + Mechanize 异步任务

python - Windows 10 版 Geopandas 安装

python - 使用 drag_and_drop_by_offset 时抓取光标(Python/Selenium)

java - NG 和 JUnit 框架的区别??哪个最适合使用 Selenium Web 驱动程序进行测试

python - 如何在从 manage.py 中定义的环境变量导入设置的项目上运行 django-pytest

java - Selenium Webdriver 将鼠标移动到 Point

python - 具有唯一 ID 的元素的替代选择 - python selenium?