Package: python3-seleniun
Version: 4.24.4+dfsg-1
The Python bindings for Selenium are no longer able to start Chromium on
x86_64 on a fresh install. The error says it cannot obtain a working
Selenium Manager. It's probably possible to work around this by
installing some components manually, but this used to work out of the
box in previous Debian releases. It feels like a regression that this
no longer works on Debian 13 (trixie).
Steps to reproduce this as root on a fresh trixie install:
```
# apt-get install python3-selenium
# cat > test.py <<EOF
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument("--headless=new")
options.add_argument("--no-sandbox")
driver = webdriver.Chrome(options=options)
driver.quit()
EOF
# python3 test.py
```
This script is very standard usage that's similar to the example given
in lots of introductions to Selenium, e.g.:
* https://www.selenium.dev/documentation/
* https://tecadmin.net/setup-selenium-with-python-on-ubuntu-debian/
* https://github.com/qxf2/selenium-beginners/blob/master/01_Navigate_Url.py
I expect it to take a second or so to initialise Chromium, and then exit
successfully without output; however, it fails with the following output:
```
Traceback (most recent call last):
File
"/usr/lib/python3/dist-packages/selenium/webdriver/common/driver_finder.py",
line 67, in _binary_paths
output = SeleniumManager().binary_paths(self._to_args())
File
"/usr/lib/python3/dist-packages/selenium/webdriver/common/selenium_manager.py",
line 47, in binary_paths
args = [str(self._get_binary())] + args
~~~~~~~~~~~~~~~~^^
File
"/usr/lib/python3/dist-packages/selenium/webdriver/common/selenium_manager.py",
line 99, 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 "/root/test.py", line 7, in <module>
driver = webdriver.Chrome(options=options)
File
"/usr/lib/python3/dist-packages/selenium/webdriver/chrome/webdriver.py",
line 45, in __init__
super().__init__(
~~~~~~~~~~~~~~~~^
browser_name=DesiredCapabilities.CHROME["browserName"],
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<3 lines>...
keep_alive=keep_alive,
^^^^^^^^^^^^^^^^^^^^^^
)
^
File
"/usr/lib/python3/dist-packages/selenium/webdriver/chromium/webdriver.py",
line 50, in __init__
if finder.get_browser_path():
~~~~~~~~~~~~~~~~~~~~~~~^^
File
"/usr/lib/python3/dist-packages/selenium/webdriver/common/driver_finder.py",
line 47, in get_browser_path
return self._binary_paths()["browser_path"]
~~~~~~~~~~~~~~~~~~^^
File
"/usr/lib/python3/dist-packages/selenium/webdriver/common/driver_finder.py",
line 78, in _binary_paths
raise NoSuchDriverException(msg) from err
selenium.common.exceptions.NoSuchDriverException: Message: Unable to
obtain driver for chrome; For documentation on this error, please visit:
https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location
```
The server has Chromium version 145.0.7632.109-1~deb13u3 (together with
the same versions of chromium-common, chromium-driver and
chromium-standbox) from Debian.
The --no-sandbox option is passed to Chromium to allow it to run as
root, which I'm doing here to simplify the example; if you create a
non-root user and run the test script as that, you can remove that
option, but it fails in exactly the same way, so I don't think that's
relevant.
Precisely the same steps on a fresh Debian 12 (bookworm) install works
fine, by which I mean the program exits without printing any output and
more complicated test scripts suggest it really is working correctly.
The Debian 12 server is running Selenium 4.8.3+dfsg-1 and Chromium
145.0.7632.109-1~deb12u3.
If I install strace and trace the script on Debian 12, this tells me it
loads
/usr/lib/python3/dist-packages/selenium/webdriver/common/selenium_manager.py,
and then executes /usr/bin/chromedriver and then /usr/bin/chromium. On
Debian 13, it still loads selenium_manager.py, but does not attempt to
execute chromedriver, chromium or anything else. Instead, it attempts
to newfstatat(2)
/usr/lib/python3/dist-packages/selenium/webdriver/common/linux/selenium-manager,
which does not exist. It does not attempt to do this to this on Debian
12. Running `find / -name \*selenium-manager\*` finds nothing on either
Debian 12 or 13.
I haven't tested on Debian 11 (bullseye), but I'm pretty confident this
script would have worked fine out of the box there. There isn't a newer
package for me to test in either forky or sid.
It seems to me that there is probably a missing dependency here: that
the python3-selenium package in Debian 13 needs to depend on something
to provide selenium-manager, however I've not been able to work out
which package (if any) does provide that on Debian 13.
I suspect that this bug is the same as this one reported upstream as
occurring in Ubuntu 23.10 which apparently ships with Selenium 4.11.2
(i.e. a more recent version than Debian 12, though substantially older
than Debian 13's):
https://github.com/SeleniumHQ/selenium/issues/14130
The Selenium developers didn't seem interested in investigating a
problem in anything other than the newest upstream version, which that
wasn't. They say you should install Selenium with pip and ignore the
distribution's copy.