1

I absolutely cannot set the system path for the geckodriver for firefox. Using osx, I have the following working just fine in Chrome:

driver = webdriver.Chrome('/Users/Robert/Applications/chromedriver')

But I need firefox to set up a profile so I can automatically login to company site etc. So I tried the following with python:

driver = webdriver.Firefox('/Users/Robert/Applications/geckodriver')
driver.get('http://www.google.com.au')

Have updated to firefox 50.x.x, tried different paths, re-downloading, and running the following also:

driver = webdriver.Firefox()

but still no dice. I am absolutely 100% the location is correct

Error msg: no such file or directory. Using latest python 2.7.xx

Mohsin Awan
  • 1,176
  • 2
  • 12
  • 29
Rob
  • 41
  • 5
  • Are you definitely using Selenium version 3 onwards? As far as I'm aware only Selenium 3.0 onwards requires the Geckodriver path to be specified. Also, I don't think you start the Firefox Webdriver with the Geckodriver path; you have to set it as a system variable and just start the Firefox driver as normal i.e. `System.setProperty("webdriver.gecko.driver", "/Users/username/Downloads/geckodriver"); WebDriver driver = new FirefoxDriver();` – Dillanm Jan 23 '17 at 11:34
  • Turns out I had to add the folder location to my system path directly in the terminal interface. My system path is super long now (because I stuffed up a bit) does this matter? export PATH=$PATH – Rob Jan 23 '17 at 23:24

2 Answers2

0

I have a lot of success putting the external drivers selenium uses, into system paths. If you can call it on the command line, python can call it.

My current .bashrc has:

export FF_DRIVER_PATH='/Users/sel_user/Applications/geckodriver'
export CH_DRIVER_PATH='/Users/sel_user/Applications/chromedriver'
export PATH=$PATH:$FF_DRIVER:$CH_DRIVER_PATH

Easy enough to do in python w/ os library: How to set environment variables in Python

Community
  • 1
  • 1
NanoMage
  • 121
  • 7
0

Well, the FF/Selenium scenario has changed those past "days".

U have 3 options at all: 1- Add geckodriver to path (system path) then simply run webdriver.Firefox() 2- Add geckodriver at the root folder of your script, so it's "on path" then run webdriver.Firefox() 3- Use the FirefoxBinary() property, already explained here: https://stackoverflow.com/a/25715497/2480481

In my case, i always ship a copy of the drivers involved, so i don't really use the path, or i do append the subfolder to path "within" the script.

Community
  • 1
  • 1
m3nda
  • 1,986
  • 3
  • 32
  • 45