-1

Hi guys I'm in need of assistance.

So i have the latest version of python and i was able to push pip install selenium. When i run a script it says this message

Traceback (most recent call last):
  File "C:\Users\huHMONGous\Desktop\Python 3.6\Scripts\new.py", line 4, in <module>
    driver = webdriver.Firefox()
  File "C:\Users\huHMONGous\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 142, in __init__
    self.service.start()
  File "C:\Users\huHMONGous\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: 'geckodriver' executable needs to be in PATH.

I have windows 10. I have downloaded geckodriver-v0.18.0-win64zip. I extracted it and copy and paste into both user variable and system variable path and it still won't work. Can anyone please help?? I am using notepad++ and command prompt to run my code

Code i'm trying to run

from selenium import webdriver
driver = webdriver.Firefox()
driver.get("https://www.youtube.com")
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
huhmongous
  • 1
  • 1
  • 2
  • No need to say **`Thank you`**. You say **`Thanks`** when you select the `Best` **`Answer`** as a **`Solution`** to your Question and **`Upvote`** the Answers which was **`Useful`** to you. Thanks – undetected Selenium Aug 04 '17 at 04:11
  • Duplicate, a simple Google search of the error and I found [this](https://stackoverflow.com/questions/40208051/selenium-using-python-geckodriver-executable-needs-to-be-in-path) and [this](https://stackoverflow.com/questions/40188699/webdriverexception-message-geckodriver-executable-needs-to-be-in-path). Please try to search yourself before ask a question. – Zcode Aug 04 '17 at 11:48

1 Answers1

0

Here is the Answer to your Question:

When you work with Selenium 3.4.3, geckodriver v0.18.0, Mozilla Firefox 53.0 through Python 3.6.x bindings you can use the following code block to open the url https://www.youtube.com.

Once you download and extract the geckodriver executable, you can keep it anywhere on your system and explicitly call them in your scripts without worrying about copy-paste into User Variable and System Variable path. Hence you achieve the flexibility of working with multiple versions of the geckodriver executable as per your requirement.

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary('C:\\Program Files\\Mozilla Firefox\\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary, executable_path=r'C:\\Utility\\BrowserDrivers\\geckodriver.exe')
driver.get('https://www.youtube.com')

Let me know if this Answers your Question.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352