Selenium-Python 与 chromium 浏览器 (windows)

Selenium-Python with chromium browser (windows)

我正在尝试在 windows 8.

上使用 selenium python 启动 chromium 浏览器

添加 binary_location 作为 chromium 二进制位置,即 appdata。 但仍然 chrome 驱动程序启动 google chrome 而不是铬。

如果我卸载 google chrome,那么 chrome 驱动程序默认启动 Chromium。但是安装 chrome 后,无论如何它总是会启动 chrome。

有人知道如何在安装 chrome 时用硒启动铬吗?

请不要将其标记为重复。另一个是关于 unix 和提供给 selenium java 的解决方案,而这个是关于 windows 和 python.

试试这个:

from selenium.webdriver.chrome.options import Options

options = Options()
options.binary_location = r"D:\.....\chrome.exe"
# This line defines your Chromium exe file location.

driver = webdriver.Chrome(chrome_options=options)
driver.get('https://www.google.com/')

对我有用。 我安装了 Chrome 和 Chromium。 它启动指定的 exe。

要启动 Chromium 浏览器,您可以使用以下代码块:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.binary_location("C:\path\to\chrome.exe") //path to chromium binary
options.add_argument("start-maximized")
options.add_argument("--disable-gpu-vsync") //only for Windows
options.add_argument("--remote-debugging-port=9222") //for MAC & Linux
driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe', chrome_options=options)
driver.get('http://google.com/')

Note : Here you can find more details about Run Chromium with flags