-1

I'm a total beginner to Python and I'm trying to use Selenium

I installed Selenium using this video tutorial https://www.youtube.com/watch?v=0vsswJooDe0. I was able to follow the tutorial up to 11 min 10 seconds. I tried saving the script in multiple locations, including in the paths that were added when installing Selenium.

This is the script I am trying to run

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("www.google.com")

This is the error that is showing up

 RESTART: C:/Users/cindy/AppData/Local/Programs/Python/Python36-32/sample.py 
Traceback (most recent call last):
  File "C:\Users\cindy\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
stdin=PIPE)
  File "C:\Users\cindy\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 709, in __init__
restore_signals, start_new_session)
  File "C:\Users\cindy\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 997, 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 "C:/Users/cindy/AppData/Local/Programs/Python/Python36-32/sample.py", line 5, in <module>
driver = webdriver.Firefox()
  File "C:\Users\cindy\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 152, in __init__
self.service.start()
  File "C:\Users\cindy\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 

Can someone tell me what I've done wrong and how to fix this? Thanks!

  • 1
    Possible duplicate of https://stackoverflow.com/questions/40208051/selenium-using-python-geckodriver-executable-needs-to-be-in-path – Vimanyu Mar 19 '18 at 16:32

1 Answers1

0

Selenium relies on additional bindings specific for each browser. First, install the driver from here, selecting the download for your specific OS. Then, pass the download path to the constructor:

driver = webdriver.Firefox("path/to/geckodriver/on/yourcomputer")
Ajax1234
  • 69,937
  • 8
  • 61
  • 102