Vivek22
Vivek22

Reputation: 858

Unable to open firefox using selenium-python-geckodriver

Newbee here! Help out guys!

Environment: Windows 10.1 (64Bit) + Selenium + Python + geckodriver.exe (latest version - v0.13.0 - https://github.com/mozilla/geckodriver/releases)

Issue:

Code Used:

from selenium import webdriver
path = 'C:\Program Files (x86)\Python36-32\Lib\site-packages\selenium\webdriver\firefox\geckodriver.exe'
browser = webdriver.Firefox(path)
browser.get("https://www.google.com/")

Note:

Questions:

  1. What is the issue? Gave correct location path. Still unable to open
  2. Is path set in environment variables above is correct? I tried changing it many times and no use. Could someone please share your working environment variable path?

Kindly reply! Thanks for your time!

Upvotes: 0

Views: 5032

Answers (3)

Naveen Kumar R B
Naveen Kumar R B

Reputation: 6398

Add the following value to PATH :

  1. C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\firefox (i.e., till geckodriver.exe)

When looking for files/exes in that PATH, it won't look inside the sub-folders of that path.

Or

Keep the geckodriver.exe in one of the following paths, which are already added to PATH:

 1. C:\Program Files (x86)\Python36-32\Scripts
 2. C:\Program Files (x86)\Python36-32
 3. C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver

Note: System Restart may be necessary.

Upvotes: 0

user4999758
user4999758

Reputation: 41

try to use executable_path , this param use to specify the path to run geckodriver

base_path = "./"
driver = webdriver.Firefox(executable_path=os.path.join(base_path, "geckodriver"), **config)

Upvotes: 1

Andersson
Andersson

Reputation: 52665

Please try following and let me know whether it solved your issue or not

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

path = 'C:\Program Files (x86)\Python36-32\Lib\site-packages\selenium\webdriver\firefox\geckodriver.exe'
binary = FirefoxBinary('C:\Path\to\firefox.exe') # Set your own path
browser = webdriver.Firefox(path, firefox_binary=binary)

Upvotes: 0

Related Questions