11

os:windows 7 selenium version 3.0.1 mozilla firefox:48.0.2

Traceback (most recent call last):
  File "C:\Users\LENOVO\Desktop\kk2.py", line 4, in <module>
  driver = webdriver.Firefox()
  File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 135, in __init__
  self.service.start()
  File "C:\Python27\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start
  os.path.basename(self.path), self.start_error_message)
  WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 

please give information step by step thoroughly please actually i am learner

the-run
  • 977
  • 1
  • 10
  • 21
pratap
  • 105
  • 1
  • 1
  • 5
  • same issue here...same environment... – Naveen Kumar R B Oct 26 '16 at 14:21
  • 1
    you may downgrade your selenium by pip install selenium==2.53.6 – Vinay Nov 21 '16 at 06:02
  • Worked for me as well for windows 7. I downgraded the selenium version to 2.53.6. However I could not get the reason why it is not working with selenium version 3.4.2 – Roshni Tiwari Jun 12 '17 at 06:56
  • 1
    Possible duplicate of [Selenium using Python - Geckodriver executable needs to be in PATH](https://stackoverflow.com/questions/40208051/selenium-using-python-geckodriver-executable-needs-to-be-in-path) – Antwane Jul 26 '17 at 10:15

5 Answers5

24

For Linux based system, download geckodriver. Extract it and copy the driver to /usr/local/bin and finally make it executable (chmod +x geckodriver).

ahereza
  • 466
  • 5
  • 10
6

please check the answer:

https://stackoverflow.com/a/37765661

https://stackoverflow.com/a/40208762

Shortly,

From selenium 3.0, you have to explicitly download Marionette geckodriver for Firefox (which is similar to ChromeDriver for Chrome) and keep it in a place where the system can identify it. (like System PATH - environmental variables in Windows) or specify using language options.

References:

  1. Download Marionette GeckoDriver
  2. https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver
  3. https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette
Community
  • 1
  • 1
Naveen Kumar R B
  • 6,248
  • 5
  • 32
  • 65
4

Linux(Ubuntu) Users should download the geckodriver and extract it in your project folder and while running your python script give the argument as

executable_path="./geckodriver"

Example:

from selenium import webdriver

class RunFFTests():

    def testMethod(self):
        # Initiate the driver instance
        driver = webdriver.Firefox(
            executable_path="./geckodriver")

        driver.get("http://www.letskodeit.com")

ff = RunFFTests()
ff.testMethod()
Andronicus
  • 25,419
  • 17
  • 47
  • 88
3

For mac users use:

brew install geckodriver
elad silver
  • 9,222
  • 4
  • 43
  • 67
3

I just download Gecko file and paste in where your python file is. It solves the problem!

Emily Chen
  • 123
  • 1
  • 1
  • 9