#1053996#5
Date:
2023-10-15 14:33:57 UTC
From:
To:
It seems the packaged version can't find geckodriver even though it's in
$PATH.

Step 1: Downloading geckodriver from documented link
https://selenium-python.readthedocs.io/installation.html#drivers:

```
curl -L
https://github.com/mozilla/geckodriver/releases/download/v0.33.0/geckodriver-v0.33.0-linux64.tar.gz
| tar xzf -
mv geckodriver /bin
```

Step 2: Running python snippet taken from
https://selenium-python.readthedocs.io/getting-started.html#example-explained:

```
from selenium import webdriver
driver = webdriver.Firefox()
```

Yields a failure accessing an undocumented env variable:

```
Traceback (most recent call last):
   File
"/usr/lib/python3/dist-packages/selenium/webdriver/common/driver_finder.py",
line 38, in get_path
     path = SeleniumManager().driver_location(options) if path is None
else path
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File
"/usr/lib/python3/dist-packages/selenium/webdriver/common/selenium_manager.py",
line 81, in driver_location
     args = [str(self.get_binary()), "--browser", browser]
                 ^^^^^^^^^^^^^^^^^
   File
"/usr/lib/python3/dist-packages/selenium/webdriver/common/selenium_manager.py",
line 60, in get_binary
     if not path.is_file() and os.environ["CONDA_PREFIX"]:
                               ~~~~~~~~~~^^^^^^^^^^^^^^^^
   File "<frozen os>", line 679, in __getitem__
KeyError: 'CONDA_PREFIX'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File
"/usr/lib/python3/dist-packages/selenium/webdriver/firefox/webdriver.py",
line 59, in __init__
     self.service.path = DriverFinder.get_path(self.service, options)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File
"/usr/lib/python3/dist-packages/selenium/webdriver/common/driver_finder.py",
line 41, in get_path
     raise NoSuchDriverException(msg) from err
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
```

So I made the variable exist, but let it empty:

```
Traceback (most recent call last):
   File
"/usr/lib/python3/dist-packages/selenium/webdriver/common/driver_finder.py",
line 38, in get_path
     path = SeleniumManager().driver_location(options) if path is None
else path
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File
"/usr/lib/python3/dist-packages/selenium/webdriver/common/selenium_manager.py",
line 81, in driver_location
     args = [str(self.get_binary()), "--browser", browser]
                 ^^^^^^^^^^^^^^^^^
   File
"/usr/lib/python3/dist-packages/selenium/webdriver/common/selenium_manager.py",
line 65, in get_binary
     raise WebDriverException(f"Unable to obtain working Selenium
Manager binary; {path}")
selenium.common.exceptions.WebDriverException: Message: Unable to obtain
working Selenium Manager binary;
/usr/lib/python3/dist-packages/selenium/webdriver/common/linux/selenium-manager


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File
"/usr/lib/python3/dist-packages/selenium/webdriver/firefox/webdriver.py",
line 59, in __init__
     self.service.path = DriverFinder.get_path(self.service, options)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File
"/usr/lib/python3/dist-packages/selenium/webdriver/common/driver_finder.py",
line 41, in get_path
     raise NoSuchDriverException(msg) from err
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
```

And on bookworm, it's not much better:

```
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File
"/usr/lib/python3/dist-packages/selenium/webdriver/firefox/webdriver.py",
line 199, in __init__
     super().__init__(command_executor=executor, options=options,
keep_alive=True)
   File
"/usr/lib/python3/dist-packages/selenium/webdriver/remote/webdriver.py",
line 286, in __init__
     self.start_session(capabilities, browser_profile)
   File
"/usr/lib/python3/dist-packages/selenium/webdriver/remote/webdriver.py",
line 378, in start_session
     response = self.execute(Command.NEW_SESSION, parameters)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File
"/usr/lib/python3/dist-packages/selenium/webdriver/remote/webdriver.py",
line 440, in execute
     self.error_handler.check_response(response)
   File
"/usr/lib/python3/dist-packages/selenium/webdriver/remote/errorhandler.py",
line 245, in check_response
     raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: Expected
browser binary location, but unable to find binary in default location,
no 'moz:firefoxOptions.binary' capability provided, and no binary flag
set on the command line
```

#1053996#10
Date:
2025-02-18 15:00:01 UTC
From:
To:
I still don't know why selenium cannot find a driver even if I provide
the path to it via a Service class:

service = ChromeService()
service.executable_path = r"/usr/bin/chromedriver"
driver = webdriver.Chrome(options=opts, service=service)

But I got it working via the selenium-manager CLI [1]. I installed via:

cargo install --path .

then added the path to rust binaries to my PATH and exported
SE_MANAGER_PATH like this:

export SE_MANAGER_PATH=/home/user/.cargo/bin/selenium-manager

Looks like Arch Linux created a dedicated package for this CLI tool
[2] and we need it for Debian too.

[1] https://github.com/SeleniumHQ/selenium/tree/trunk/rust
[2] https://aur.archlinux.org/packages/selenium-manager