JustZap
JustZap

Reputation: 17

Selenium: Geckodriver in PATH, but nothing changed, same error saying it isn't there

When trying to do a simple line of code with selenium, it keeps saying that I have to use geckodriver in PATH. After some research, it said to put it in the system environment variables. I put the executable file as the value and saved it. I restarted the computer and tried to run my code again and it gave the same error again. I'm not sure what to do now.

Error:

Traceback (most recent call last):
  File "c:\Users\CitizenZap\Downloads\AutoBuyer-master\AutoBuyer-master\test1.py", line 3, in <module>
    browser = webdriver.Firefox()
  File "C:\Users\CitizenZap\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 174, in __init__
    self.service.start()
  File "C:\Users\CitizenZap\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.

The code I'm writing:

from selenium import webdriver
    
browser = webdriver.Firefox()
browser.get('http://selenium.dev/')

Upvotes: 0

Views: 514

Answers (1)

PSR
PSR

Reputation: 261

Firstly, make sure the PATH to geckodriver is added as an environment variable.

Second,

browser = webdriver.Firefox()

the above stmt. is incorrect.This is why you get this error

.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.

it is supposed to be like this,

driver = webdriver.Firefox(executable_path = "geckodriver PATH")

put in this line finally,

driver.get('http://selenium.dev/')

It will work.

Upvotes: 2

Related Questions