0

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.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
andyandrade
  • 1
  • 1
  • 1
  • 1

2 Answers2

1

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.

D.L
  • 4,339
  • 5
  • 22
  • 45
  • If your first line is true, you should vote to close as a duplicate and not answer the question. [answer] – Rob Mar 26 '22 at 09:56
  • @Rob, noted. I edited the comment because i always find myself comming back to this and having to search. (I will certainly close duplicates going forwards, so thanks for pointing this out). – D.L Mar 26 '22 at 10:13
  • Again, if it's a duplicate, it should be closed. So why not close it now? – Rob Mar 26 '22 at 10:18
  • because the answers have always pointed to `matching the versions` (which i have used, but struggled with) and i prefer this method. So i would actually like it to be documented (as i will probably refer back to it myself)... – D.L Mar 26 '22 at 10:23
  • I appreciate your answer and found it useful. I wasn't able to resolve my issues using the other answers, but had success once I installed webdriver-manager. – bean Sep 27 '22 at 15:44
  • On Mac it works for me but on Linux it doesn't, I get: selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary – Chiel Jan 22 '23 at 13:56
  • @D.L this doesn't work with Chrome Beta though. Any suggestions? – Tendekai Muchenje Feb 21 '23 at 15:27
0

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:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352