【问题标题】:webdriver_manager opens google chrome instead of bravewebdriver_manager 打开 google chrome 而不是 brave
【发布时间】:2022-12-18 05:51:46
【问题描述】:

webdriver_manager 网站有一个用 brave 启动 webdriver 的代码,但它不是用 brave 打开它,而是用 google chrome。我的 selenium 版本 4.6.0 为 selenium 4 提供了以下代码(我也尝试了 selenium 3 的给定代码),因为它可以在网站上看到,但 webdriver 仍然使用 chrome 打开

# selenium 4

from selenium import webdriver
from selenium.webdriver.chrome.service import Service as BraveService
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.core.utils import ChromeType

driver = webdriver.Chrome(service=BraveService(ChromeDriverManager(chrome_type=ChromeType.BRAVE).install()))

driver.get("https://pypi.org/project/webdriver-manager/")

【问题讨论】:

    标签: python webdriver webdriver-manager


    【解决方案1】:

    好的,所以你只想用 Brave 浏览器而不是 chrome 启动驱动程序?这是我如何简单地做到这一点,请记住我在 Mac 上。您需要应用程序的二进制 PATH。

    add_block_ext = "Path to .crx extension"
    driverPath = 'chromedriver'
    binaryPath = '/Applications/Brave Browser.app/Contents/MacOS/Brave Browser'
    options = webdriver.ChromeOptions()
    options.binary_location = binaryPath
    options.add_extension(add_block_ext)
    browser = webdriver.Chrome(executable_path=binaryPath, chrome_options=options)
    browser.get("https://www.google.com")
    

    【讨论】:

      猜你喜欢
      • 2019-10-10
      • 1970-01-01
      • 2017-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-24
      • 1970-01-01
      • 2016-06-19
      相关资源
      最近更新 更多