0

I am new to Python, never coded anything before and I'm simply trying to use selenium to open google but it keeps giving me a traceback I don't understand. What is going on?

This is the code I'm trying to run:

from selenium import webdriver

driver = webdriver.Chrome()
driver.get('https://www.google.com')

This is the traceback error it keeps giving me:

Traceback (most recent call last):
  File "C:\Users\donbr\PycharmProjects\Seleniumtes\venv\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "C:\Users\donbr\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\donbr\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/donbr/PycharmProjects/Seleniumtes/Selenium Test.py", line 3, in <module>
    driver = webdriver.Chrome()
  File "C:\Users\donbr\PycharmProjects\Seleniumtes\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
    self.service.start()
  File "C:\Users\donbr\PycharmProjects\Seleniumtes\venv\lib\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


Process finished with exit code 1
halfer
  • 19,824
  • 17
  • 99
  • 186
Db949
  • 1
  • [Python Selenium Chrome Webdriver](https://stackoverflow.com/questions/42478591/python-selenium-chrome-webdriver) look here, maybe it will help you: – Eisenbiegler Jun 27 '20 at 16:02

1 Answers1

0

You haven't downloaded the chrome driver in your path.Please downloaded the driver version based on your chorme version and try it

Arun Sivaraj
  • 93
  • 1
  • 8
  • Getting syntax errors. I tried this first: from selenium import webdriver driver = webdriver.Chrome(C:\Webdriver) driver.get('http://www.google.com') & got this: File "C:/Users/donbr/PycharmProjects/Seleniumtes/Selenium Test.py", line 3 driver = webdriver.Chrome(C:\Webdriver) ^ SyntaxError: invalid syntax Took out the 'C:' just for it to say this: File "C:/Users/donbr/PycharmProjects/Seleniumtes/Selenium Test.py", line 3 driver = webdriver.Chrome(C:\Webdriver) ^ SyntaxError: invalid syntax – Db949 Jun 27 '20 at 21:19