Reputation: 2075
I'm very familiar with using chromedriver for selenium, im now trying to using geckdriver instead but for some reason I keep getting the error 'geckodriver' executable needs to be in PATH.
I followed the steps in Selenium using Python - Geckodriver executable needs to be in PATH
I added gecko driver to path in environment variables
I updated firefox to the latest version
I used the binary method
Put the geckodriver in my folder where my script is
I restarted my computer
But none of these methods seem to work, is there something I'm missing?
Here's my code
from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = FirefoxBinary("C:\\Users\\ojadi\\Downloads\\geckodriver-v0.28.0-win64\\geckodriver.exe")
browser = webdriver.Firefox(firefox_binary=binary)
Upvotes: 1
Views: 3059
Reputation: 12018
Two settings which are often overlooked in installation guides:
MAC: To add geckodriver to your profile:
open ~/.zshrc
export PATH=$PATH:/usr/local/bin/geckodriver
(Assuming this is the location of your geckodriver, if not, replace with location.)source ~/.zshrc
MAC: To make geckodriver executable:
sudo chmod +x /usr/local/bin/geckodriver
(or path to geckodriver exectable)Upvotes: 0
Reputation: 193098
You can download and store the GeckoDriver executable anywhere with in your system and you need to do pass the absolute path of firefox
binary through the attribute binary_location
as follows:
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.binary_location = r'C:\Program Files\Mozilla Firefox\firefox.exe'
driver = webdriver.Firefox(firefox_options=options, executable_path=r'C:\Users\\ojadi\Downloads\geckodriver-v0.28.0-win64\geckodriver.exe')
driver.get('http://google.com/')
Upvotes: 1