【问题标题】:Disable python chrome driver extensions without lose driver path禁用 python chrome 驱动程序扩展而不丢失驱动程序路径
【发布时间】:2016-07-06 14:16:57
【问题描述】:

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

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

非常感谢。

【问题讨论】:

    标签: python selenium


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-12
      • 2016-06-21
      • 1970-01-01
      • 1970-01-01
      • 2022-01-28
      • 2019-01-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多