-1
from selenium import webdriver
url = 'https://www.youtube.com/watch?v=CHUxmVVH2AQ'
browser = webdriver.Chrome()
browser.get(url)
browser.find_element_by_xpath('//*[@id="thumbnail"]').click()

ERROR

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/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 951, 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 1823, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/Jasiu/PycharmProjects/pythonProject/Python project/webscaper.py", line 3, in <module>
    browser = webdriver.Chrome()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
    self.service.start()
  File "/Library/Frameworks/Python.framework/Versions/3.9/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
Sven Eberth
  • 3,057
  • 12
  • 24
  • 29
  • 2
    Does this answer your question? [Error message: "'chromedriver' executable needs to be available in the path"](https://stackoverflow.com/questions/29858752/error-message-chromedriver-executable-needs-to-be-available-in-the-path) – Sven Eberth Jun 06 '21 at 21:59

1 Answers1

0

Maybe the problem is there is no chromedriver executable, you can find it here: https://chromedriver.chromium.org/downloads

url = 'https://www.youtube.com/watch?v=CHUxmVVH2AQ'
browser = webdriver.Chrome("C:\development\chromedriver.exe") # <- Path to chromedriver
browser.get(url)
browser.find_element_by_xpath('//*[@id="thumbnail"]').click()
Kitten
  • 56
  • 1
  • 3