2

I am on Windows pro 10 and using Firefox to execute the python selenium program. Trying to run:

from selenium import webdriver
wb = webdriver.Firefox()
wb.get("https://stackoverflow.com")

Getting the following error(please ignore the web browser in the error message) :

Traceback (most recent call last):
  File "C:\Users\dilri\AppData\Local\Programs\Python\Python36-32\lib\site-       packages\selenium\webdriver\common\service.py", line 74, in start
    stdout=self.log_file, stderr=self.log_file)
  File "C:\Users\dilri\AppData\Local\Programs\Python\Python36-  32\lib\subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "C:\Users\dilri\AppData\Local\Programs\Python\Python36-     32\lib\subprocess.py", line 990, 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 "H:\temp.py", line 2, in <module>
    driver = webdriver.Chrome()
  File "C:\Users\dilri\AppData\Local\Programs\Python\Python36-32\lib\site-   packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__
    self.service.start()
  File "C:\Users\dilri\AppData\Local\Programs\Python\Python36-32\lib\site-  packages\selenium\webdriver\common\service.py", line 81, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver'     executable needs to be in PATH. Please see     https://sites.google.com/a/chromium.org/chromedriver/home

1 Answers1

0

As clearly mentioned in the error message, very first install the appropriate browser driver and give its path to the system variable path. Like in my case:

from selenium import webdriver
driver_path = r"G:\Python\geckodriver.exe" #since on windows use raw strings 
wb = webdriver.Firefox(executable_path=driver_path)

# to check if it's working
wb.get("https://stackoverflow.com")

Remember: the driver path must be a raw string since we are working on windows. Also, see to it that you don't give the file name as selenium.py