Do you have questions ? We got the answers!

Ask a question:

1
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.

Open 2 Answers 4519 Views

I am getting below error with my selenium script.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary('C:\Program Files (x86)\Mozilla Firefox\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary)
driver.maximize_window()
driver.get("http://mayurshah.in")
assert "" in driver.title
elem = driver.find_element_by_css_selector("li.qa-nav-main-item:nth-child(5) > a:nth-child(1)")
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "Nothing Found" in driver.page_source
driver.close()
 

Command

C:\Users\mail_xe7zkvh\Documents>py chennaipydemo.py

Error:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 64, in start
    stdout=self.log_file, stderr=self.log_file)
  File "C:\Program Files (x86)\Python35-32\lib\subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "C:\Program Files (x86)\Python35-32\lib\subprocess.py", line 1224, in _execute_child
    startupinfo)
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 "chennaipydemo.py", line 6, in <module>
    driver = webdriver.Firefox(firefox_binary=binary)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 135, in __init__
    self.service.start()
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.

Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x00A0EBD0>>
Traceback (most recent call last):
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 163, in __del__
    self.stop()
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 135, in stop
    if self.process is None:
AttributeError: 'Service' object has no attribute 'process'

2 Answers

1

Its looking for geckodriver.

Download geckodriver from below location and add it to your PATH veriable.

https://github.com/mozilla/geckodriver/releases

Exit existing command line and reopen the same. This should help you.

answered Oct 24, 2016 by stbadmin (4,970 points)
0
answered Sep 6 by ChatBot (196 points)

Top Contributors

  • 4970 pointsstbadmin

    34 questions 454 answers218 comments

  • 433 pointsSunilBhaskar

    41 questions 15 answers32 comments

  • 425 pointsMehedi

    36 questions 3 answers14 comments

  • 363 pointssumitkumarwatts

    0 questions 13 answers0 comments

  • 354 pointsSoft Tester

    43 questions 0 answers4 comments

  • 327 pointsKeeshaGolden

    0 questions 17 answers2 comments

  • 322 pointsVipul Sharma

    44 questions 0 answers24 comments

  • 310 pointsvysh.sharma

    25 questions 0 answers0 comments

  • 267 pointsOnkar_Nimje

    33 questions 15 answers15 comments

  • 258 pointsVanitha

    26 questions 0 answers6 comments

...