【问题标题】:Trying to load chrome webdriver with extension installed,尝试加载安装了扩展的 chrome webdriver,
【发布时间】:2020-06-01 08:40:43
【问题描述】:

我正在尝试加载安装了扩展程序的 chrome 网络驱动程序(按照“How to load extension within chrome driver in selenium with python”中提到的步骤),但无法找到已安装的扩展程序,请您帮我解决这个问题,我正在尝试的代码是。

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_extension('C:/Users/john/Desktop/john/v1.10.0.0.crx')
driver = webdriver.Chrome()
driver.get('https://www.google.co.in')

它只是启动并打开带有谷歌页面的 chrome 网络驱动程序,我正在尝试使用安装的扩展程序打开这是否可以使用 selenium,任何人都可以帮忙

【问题讨论】:

    标签: python selenium selenium-webdriver


    【解决方案1】:

    尝试调用

    driver = webdriver.Chrome(chrome_options=chrome_options)
    

    而不仅仅是

    driver = webdriver.Chrome()
    

    【讨论】:

      【解决方案2】:

      我可以提供用java编写的代码,运行良好

      File file = new File("path_to_your_extension");
      
      String path = file.getAbsolutePath();
      
      ChromeOptions options = new ChromeOptions();
      
      options.addExtensions(new File(path))
      
      WebDriver driver = new ChromeDriver(options);
      
      driver.get("https://www.google.co.in")
      

      【讨论】:

        猜你喜欢
        • 2014-03-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-01-16
        • 1970-01-01
        • 1970-01-01
        • 2014-01-11
        • 2015-06-04
        相关资源
        最近更新 更多