0

I am trying to create Firefox webdriver but get following error message in python when I use

from selenium import webdriver
driver = webdriver.Firefox(executable_path=r'your\path\geckodriver.exe')
driver.get('http://inventwithpython.com')

I get following error:

C:\Users\Kyle\AppData\Local\Programs\Python\Python38-32\python.exe "C:/Users/Kyle/PycharmProjects/pythonProject/Datafolks/smoke tests.py"
Traceback (most recent call last):
  File "C:\Users\Kyle\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "C:\Users\Kyle\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\Kyle\AppData\Local\Programs\Python\Python38-32\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/Kyle/PycharmProjects/pythonProject/Datafolks/smoke tests.py", line 2, in <module>
    driver = webdriver.Firefox(executable_path=r'your\path\geckodriver.exe')
  File "C:\Users\Kyle\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 164, in __init__
    self.service.start()
  File "C:\Users\Kyle\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'geckodriver.exe' executable needs to be in PATH. 


Process finished with exit code 1
ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • 1
    which path do you use for `your\path\geckodriver.exe` in `driver` variable? – cheshire Sep 27 '20 at 23:15
  • Thank you so much I figured it out. I needed to use my PC path. – Anastasia Schwartz Sep 28 '20 at 01:57
  • Glad to help. Please consider answering your own question below, so that others that have similar problem or look up this question can find the answer. – cheshire Sep 28 '20 at 03:04
  • 1
    Does this answer your question? [selenium.common.exceptions.WebDriverException: Message: 'firefox' executable needs to be in PATH with GeckoDriver Firefox Selenium and Python](https://stackoverflow.com/questions/54261423/selenium-common-exceptions-webdriverexception-message-firefox-executable-nee) – Dev Sep 28 '20 at 07:20

0 Answers0