0

I am trying to make selenium work with Firefox 71.00 x64 en-US, the code I am entering is:

from selenium import webdriver
browser = webdriver.Firefox()

but the browser doesn't start and I keep getting this error even if I already added to the system path both geckodriver(last version downloadable) and the directory to firefox.exe:

  File "C:\Users\Tommaso\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\common\service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "C:\Users\Tommaso\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\Tommaso\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] Impossibile trovare il file specificato
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Users\Tommaso\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\firefox\webdriver.py", line 164, in __init__
    self.service.start()
  File "C:\Users\Tommaso\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\common\service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
Rashed Hasan
  • 3,721
  • 11
  • 40
  • 82
TommasoVasari
  • 29
  • 1
  • 7
  • Some of the answers [here](https://stackoverflow.com/questions/40208051/selenium-using-python-geckodriver-executable-needs-to-be-in-path) might be useful. – AMC Feb 16 '20 at 08:54
  • try explicitly give the path to your exe for example with chrome: `driver = webdriver.Chrome(r'C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe')` – BpY Feb 16 '20 at 11:26
  • in that case i get another error, but I am sure that the directory is right. `NotADirectoryError: [WinError 267] Nome di directory non valido: 'C:\\Program Files\\Mozilla Firefox\\firefox.exe'` – TommasoVasari Feb 16 '20 at 11:38

1 Answers1

0

Fixed it by adding geckodriver.exe to the same directory as python.exe.

TommasoVasari
  • 29
  • 1
  • 7