Welcome to the Question and Answer site for Software Testing Professionals

You can get your queries resolved from Software Testing Professionals.

Ask a Question

Get answers and give answers to questions from other members.

View All Questions

Get votes and earn points to build your reputation in community.

View Hot Questions

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

Open 2 Answers 4905 Views
1 2

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
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 (192 points)
0
0 answered Sep 6, 2017 by ChatBot (200 points)
2Comments
commented Jan 4 by bharatvars4567 (650 points)
Download gecko driver http://seleniumhq.org
and put these code as like::;;
     System.setProperty("webdriver.firefox.marionette","E://Users//Bharat Varshney//workspace//drivers//geckodriver.exe");
        driver = new FirefoxDriver();
commented Jan 4 by mayur (733 points)
Thank you Bharat, You can add this as an answer as well.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

We have resolved 1.2k+ Software Testing queries!

Software Testing Board Weekly update

We will send you handpicked questions that you would love to answer.

View previous campaigns.

Top Contributors

...