Selenium只打开Google Chrome(使用webdriver-manager)



我尝试在Brave浏览器上运行selenium而不是Google Chrome。正如文档中指出的(https://pypi.org/project/webdriver-manager/#use-with-edge),我应该准确地输入这个和Brave浏览器将运行,除了它不会在所有,它将只运行Google Chrome

这是我使用的代码:

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
import time, urllib3.request
driver = webdriver.Chrome(service=BraveService(ChromeDriverManager(chrome_type=ChromeType.BRAVE).install()))
driver.get("https://www.google.com/")
time.sleep(5)

它只会运行谷歌浏览器而不是勇敢的浏览器,任何人都可以试着帮助我在使用webdriver_manager的勇敢浏览器上运行?由于

如果您的计算机上安装了Brave Browser,您可以设置二进制位置的网页驱动程序。ChromeOptions到的位置brave.exe在你的电脑上。在我的例子中,brave浏览器程序位于这里:

"C:\Program Files (x86)\BraveSoftware\Brave-Browser\Application\brave.exe"

下面是一个示例:

代码:

# 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
option = webdriver.ChromeOptions()
option.binary_location = "C:\Program Files (x86)\BraveSoftware\Brave-Browser\Application\brave.exe"
driver = webdriver.Chrome(service=BraveService(ChromeDriverManager(chrome_type=ChromeType.BRAVE).install()), options=option)
driver.get("https://www.google.com")