1

I am trying to make a web automation bot using python and selenium but I have encountered a problem/error

Here's my code

from selenium import webdriver
from selenium.webdriver.chrome.service import Service

s=Service('C:/Users/asus/AppData/Local/Programs/Python/Python39/driverchromedriver.exe')
browser = webdriver.Chrome(service=s)
url='https://www.google.com'
browser.get(url)

And here's the eror I'm am encountered with

Traceback (most recent call last):
  File "C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

1 Answers1

0

This error message...

FileNotFoundError: [WinError 2] The system cannot find the file specified

...implies that the program can't find the mentioned executable file driverchromedriver.exe

Possibly it's a typo as in it's original form the name of the ChromeDriver executable is chromedriver.exe


Solution

Effectively the relevant line of code will be:

  • If the ChromeDriver executable is within C:/Users/asus/AppData/Local/Programs/Python/Python39/:

    s=Service('C:/Users/asus/AppData/Local/Programs/Python/Python39/chromedriver.exe')
    
  • If the ChromeDriver executable is within C:/Users/asus/AppData/Local/Programs/Python/Python39/driver/:

    s=Service('C:/Users/asus/AppData/Local/Programs/Python/Python39/driver/chromedriver.exe')
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352