2

I had a previously working python script (on 22.04) that uses the Selenium package with the Firefox driver. Now it seems that the Python Selenium package can never find the Firefox Driver geckodriver, but it's possibly the driver location.

The cited error is:

selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for firefox using Selenium Manager.; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location

The Firefox driver is available, and in the path:

# which geckodriver
/snap/bin/geckodriver

At first I thought it was the snap at fault, but even copying geckogriver to /usr/bin did not make a difference.

I tried a bunch of driver options in python, including passing the path to the driver executable, etc. etc. But none of these seemed to help.

Interestingly, the path cited in the error message does not actually exist:

# ls -la /usr/lib/python3/dist-packages/selenium/webdriver/common/linux/selenium-manager
ls: cannot access '/usr/lib/python3/dist-packages/selenium/webdriver/common/linux/selenium-manager': No such file or directory

And neither does the linux part of that, it only exists up to common.

On another machine, I installed Ubuntu 24.04 from scratch (rather than an upgrade), but hit exactly the same issue.

Kingsley
  • 388

1 Answers1

3

As a workaround, it's possible to specifically tell the webdriver where to find geckodriver ~

from selenium import webdriver
from selenium.webdriver.common.by import By

...

opts = webdriver.FirefoxOptions() serv = webdriver.FirefoxService( executable_path='/snap/bin/geckodriver' )

TODO - set some more options

ffox_driver = webdriver.Firefox( options=opts, service=serv )
ffox_driver.get( some_url )

I don't know why this works, yet relocating geckodriver into the $PATH doesn't work.

Kingsley
  • 388