Skip to content
Advertisement

Errors while compiling python code using selenium webdriver [closed]

My code is:

import time
from selenium import webdriver

driver = webdriver.Chrome('/Useres/arsenijgoj/PycharmProjects/pythonProject/chromedriver')  # Optional argument, if not specified will search path.
driver.get('http://www.google.com/');
time.sleep(5) # Let the user actually see something!
search_box = driver.find_element_by_name('q')
search_box.send_keys('ChromeDriver')
search_box.submit()
time.sleep(5) # Let the user actually see something!
driver.quit()

Error is:

Traceback (most recent call last):
  File "/Users/arsenijgoj/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 947, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1819, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/Useres/arsenijgoj/PycharmProjects/pythonProject/chromedriver'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/arsenijgoj/PycharmProjects/pythonProject/main.py", line 4, in <module>
    driver = webdriver.Chrome('/Useres/arsenijgoj/PycharmProjects/pythonProject/chromedriver')  # Optional argument, if not specified will search path.
  File "/Users/arsenijgoj/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
    self.service.start()
  File "/Users/arsenijgoj/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

Don’t know what to do. Everything is installed properly, path to the chromedriver is correct too (it’s even in the same directory as project is). Using mac air m1, PyCharm Any suggestions?

Advertisement

Answer

You have a typo in the chromedriver’s path. “users” instead of “useres”.

Change

webdriver.Chrome('/Useres/arsenijgoj/PycharmProjects/pythonProject/chromedriver')

to

webdriver.Chrome('/Users/arsenijgoj/PycharmProjects/pythonProject/chromedriver')
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement