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 server expects you to have Chrome installed in the default location for each system:
OS Expected Location of Chrome Linux /usr/bin/google-chrome1 Mac /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome Windows XP %HOMEPATH%\Local Settings\Application Data\Google\Chrome\Application\chrome.exe Windows Vista and newer C:\Users%USERNAME%\AppData\Local\Google\Chrome\Application\chrome.exe 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:
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()
Related Docs
Reference
You can find a detailed discussion in:
- Is Chrome installation needed or only chromedriver when using Selenium?