Python Selenium – unknown error: cannot find Chrome binary

Python Selenium – unknown error: cannot find Chrome binary

This error occurs when Chrome webdriver cannot find the Chrome binary on your system.

To solve this error, you can specify the location of the Chrome binary using Options.

For example, to specify the location of the Chrome binary, following these steps.

Step 1 – Get Options

Get the options property of the webdriver. It returns an Options object.

options = webdriver.ChromeOptions()
Copy

Step 2 – Set binary location

Set the binary_location property of the Options object. This step makes the location of Chrome browser binary to the webdriver.

options.binary_location = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
Copy

If you browser application is in different location, then update the value accordingly.

Step 3 – Initialize driver with the options

Create the webdriver object using the options created in the previous step.

service = ChromeService(executable_path="/usr/local/bin/chromedriver")
driver = webdriver.Chrome(service=service, options=options)
Copy

Related Tutorials

Quiz on Selenium

Q1. What is Selenium Python used for?

Not answered

Q2. What is a web driver in Selenium Python?

Not answered

Q3. What is the method used to find web elements in Selenium Python?

Not answered

Q4. What is the method used to navigate back to the previous page in Selenium Python?

Not answered

Q5. Which of the following is not a commonly used web element locator in Selenium Python?

Not answered
Code copied to clipboard successfully 👍