Home > Blockchain >  WebDriverException: unknown error: cannot find Chrome binary error when trying to run webbot using S
WebDriverException: unknown error: cannot find Chrome binary error when trying to run webbot using S

Time:03-27

I'm trying to automate a process using selenium. When I run the code it gives me the error bellow.

WebDriverException: unknown error: cannot find Chrome binary
  (Driver info: chromedriver=2.39.562718 (9a2698cba08cf5a471a29d30c8b3e12becabb0e9),platform=Windows NT 10.0.22000 x86_64)

I have downloaded the new driver and passed the variable in system variables under path. Can anyone please help me figure this out. I'm a student just starting my tech career.

CodePudding user response:

This question has been asked many times before in similar disguises and the answers have usually advised to match versions. However, i have often struggled to match versions (for various reasons) and this is rather cumbersome when the versions keep changing.

For this reason, I use the ChromeDriverManager() which installs the correct version at each time.

You need to install webdriver-manager:

pip install webdriver-manager

And this is the working code

# selenium 4
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By


service=Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=service)

You can find the docs here: https://pypi.org/project/webdriver-manager/

This module recognises and has solved a problem for us all:

It’s boring!!! Moreover every time the new version of driver released, you should go and repeat all steps again and again.

I hope it helps.

CodePudding user response:

This error message...

WebDriverException: unknown error: cannot find Chrome binary (Driver info: chromedriver=2.39.562718 

...implies that the ChromeDriver was unable to locate the executable.

Your main issue is the incompatibility between the version of the binaries you are using as follows:

  • You are using chromedriver=2.39
  • As per this discussion chromedriver=2.39 :

Supports Chrome v66-68

Supports Chrome version 99

So there is a clear mismatch between chromedriver=2.39 and the chrome=99.0


Solution

Ensure that:

  • Related