Home  >  Article  >  Backend Development  >  Why Am I Getting \"WebDriverException: Unknown Error\" in Selenium with Older Chrome Versions?

Why Am I Getting \"WebDriverException: Unknown Error\" in Selenium with Older Chrome Versions?

Barbara Streisand
Barbara StreisandOriginal
2024-11-02 09:33:03882browse

Why Am I Getting

WebDriverException: Unknown Error in Selenium with Older Chrome Versions

When using Selenium with older versions of Google Chrome, users may encounter the error "WebDriverException: unknown error: cannot find Chrome binary." This error occurs when the ChromeDriver cannot locate the Chrome binary in the expected default location.

Solution:

To resolve this issue, explicitly specify the Chrome binary location using the Options.binary_location property. This property accepts the path to the Chrome binary executable.

<code class="python">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)</code>

By providing the exact location of the Chrome binary, the ChromeDriver can accurately locate and launch Chrome, resolving the "cannot find Chrome binary" error.

The above is the detailed content of Why Am I Getting \"WebDriverException: Unknown Error\" in Selenium with Older Chrome Versions?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn