对于旧版Google Chrome,无法在Python中使用Selenium找到Chrome二进制文件

Ven*_*ian 6 python selenium google-chrome

出于兼容性原因,我更喜欢将Chrome版本55.0.2883.75与Chromedriver v.2.26一起使用。我从https://www.slimjet.com/chrome/google-chrome-old-version.php和Chromedriver 2.26从https://chromedriver.storage.googleapis.com/index.html?path下载了较旧版本的chrome = 2.26 /

我正在使用以下代码尝试设置我的Chrome二进制位置:

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

options = Options()
options.binary_location = "C:\\Program Files\\Chrome\\chrome64_55.0.2883.75\\chrome.exe"
driver = webdriver.Chrome('chromedriver.exe', chrome_options = options)
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试启动WebDriver Python时,返回以下错误:

WebDriverException: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.26.436362
(5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 10.0.14393 x86_64)
Run Code Online (Sandbox Code Playgroud)

我曾尝试搜索类似的问题和答案,但到目前为止还没有任何运气。非常感谢您的帮助-预先感谢您!

Deb*_*anB 8

此错误消息...

WebDriverException: unknown error: cannot find Chrome binary
Run Code Online (Sandbox Code Playgroud)

...暗示ChromeDriver在系统默认位置找不到Chrome二进制文件。

按照ChromeDriver-要求

ChromeDriver服务器希望你安装在每个系统的默认位置的Chrome如下:

ChromeLocation

1对于Linux系统,所述ChromeDriver预计/usr/bin/google-chrome是一个符号链接到实际的镀铬的二进制


在非标准位置使用Chrome可执行文件

但是,您还可以按如下方式覆盖默认的Chrome二进制位置

Chrome_non_standard_location


要使用通过ChromeDriver v2.26安装在非标准位置的Chrome版本55.x,可以使用以下代码块:

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

options = Options()
options.binary_location = "C:\\Program Files\\Chrome\\chrome64_55.0.2883.75\\chrome.exe"
driver = webdriver.Chrome(chrome_options = options, executable_path=r'C:\path\to\chromedriver.exe')
driver.get('http://google.com/')
print("Chrome Browser Invoked")
driver.quit()
Run Code Online (Sandbox Code Playgroud)

  • Windows 10 怎么样?它不适用于 Vista 显示的路径中名为“chrome.exe”的链接。 (2认同)