問題描述
出于兼容性原因,我更喜歡將 Chrome 版本 55.0.2883.75 與 Chromedriver v. 2.26 一起使用.我從
1 對于 Linux 系統,ChromeDriver 期望 /usr/bin/google-chrome
是 符號鏈接 到實際的 Chrome 二進制文件.
在非標準位置使用 Chrome 可執行文件
但是您也可以覆蓋默認的 Chrome 二進制位置,如下所示:
<小時>要使用通過 ChromeDriver v2.26 安裝在非標準位置的 Chrome 版本 55.x,您可以使用以下代碼塊:
從 selenium 導入 webdriver從 selenium.webdriver.chrome.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 ochromedriver.exe')driver.get('http://google.com/')print("Chrome 瀏覽器調用")driver.quit()
<小時>
參考
您可以在以下位置找到詳細討論:
- 是否需要安裝 Chrome 或使用 Selenium 時只能使用 chromedriver?
For compatibility reasons I prefer to use Chrome version 55.0.2883.75 with Chromedriver v. 2.26. I downloaded the older version of chrome from https://www.slimjet.com/chrome/google-chrome-old-version.php and Chromedriver 2.26 from https://chromedriver.storage.googleapis.com/index.html?path=2.26/.
I am using the following code to attempt to set my Chrome binary location:
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)
However, when I attempt to launch the WebDriver Python returns the following error:
WebDriverException: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.26.436362
(5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 10.0.14393 x86_64)
I have tried searching through similar questions and answers but have not had any luck so far. Any help is greatly appreciated - thank you in advance!
This error message...
WebDriverException: unknown error: cannot find Chrome binary
...implies that the ChromeDriver was unable to find the Chrome binary in the default location for your system.
As per the ChromeDriver - Requirements:
The ChromeDriver server expects you to have Chrome installed in the default location for each system as follows:
1 For Linux systems, the ChromeDriver expects /usr/bin/google-chrome
to be a symlink to the actual Chrome binary.
Using a Chrome executable in a non-standard location
However you can also override the default Chrome binary location as follows:
To use Chrome version 55.x installed in non standard location through ChromeDriver v2.26 you can use the following code block :
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 ochromedriver.exe')
driver.get('http://google.com/')
print("Chrome Browser Invoked")
driver.quit()
Reference
You can find a detailed discussion in:
- Is Chrome installation needed or only chromedriver when using Selenium?
這篇關于WebDriverException:未知錯誤:對于舊版本的 Google Chrome,在 Python 中找不到帶有 Selenium 的 Chrome 二進制錯誤的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!