-1

I'm using python (v 3.65) selenium (v3.11.0) on Mac OS X (v 10.11.6) with firefox (v 59.0.3) and geckodriver (v 0.20.1). I have my usual firefox in the Applications folder and a second firefox in another folder. How can I tell python selenium to use the second firefox instead of going to the one in Applications?

I'd prefer an answer that generalises to other browsers besides firefox/geckodriver, if possible.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • You can use `DesiredCapabilities` to firefox profile and set `binary` attribute to it. [Check this answer for implementation details](https://stackoverflow.com/a/40931903/5741172) – Sohaib Farooqi May 05 '18 at 03:28
  • The firefox_capabilities trick didn’t work. Renaming the firefox in the Applications folder caused my test script to fail with “Unable to find a matching set of capabilities”. Renaming the firefox in the other folder made no difference either way. So python/selenium/geckodriver isn’t using firefox_capabilities to find the firefox executable. Maybe this is more of a Mac OS X question than a selenium question? – PlanetAtkinson May 05 '18 at 05:42

1 Answers1

0

To choose and use one of the Firefox executable among multiple you can use the argument binary_location from firefox.options. As an example in the following code block I have used the Firefox Nightly binary to open the Firefox Nightly browser :

  • Code Block :

    from selenium import webdriver
    from selenium.webdriver.firefox.options import Options
    
    options = Options()
    options.binary_location = r'C:\Program Files\Firefox Nightly\firefox.exe'
    driver = webdriver.Firefox(firefox_options=options, executable_path=r'C:\Utility\BrowserDrivers\geckodriver.exe')
    driver.get('http://google.com/')
    print("Firefox Browser Invoked")
    driver.quit()
    
  • Console Output :

    Firefox Browser Invoked
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352