selenium: [🐛 Bug]: Selenium 4.11.x not working with Chronium.

What happened?

Latest version 4.11.x is not working with Chronium. While the same code is working fine with 4.10.0.

How can we reproduce the issue?

from selenium import webdriver

# Start selenium driver
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(options=options)
driver.get('http://example.com/')



### Relevant log output

```shell
./debugpy/launcher 49971 -- /home/ikus060/workspace/PDSL/rdiffweb.git/snippet.py 
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/ikus060/.vscode/extensions/ms-python.python-2023.12.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 39, in <module>
    cli.main()
  File "/home/ikus060/.vscode/extensions/ms-python.python-2023.12.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main
    run()
  File "/home/ikus060/.vscode/extensions/ms-python.python-2023.12.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file
    runpy.run_path(target, run_name="__main__")
  File "/home/ikus060/.vscode/extensions/ms-python.python-2023.12.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/home/ikus060/.vscode/extensions/ms-python.python-2023.12.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/home/ikus060/.vscode/extensions/ms-python.python-2023.12.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
    exec(code, run_globals)
  File "/home/ikus060/workspace/PDSL/rdiffweb.git/snippet.py", line 5, in <module>
    driver = webdriver.Chrome(options=options)
  File "/home/ikus060/workspace/PDSL/rdiffweb.git/.venv/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
    super().__init__(
  File "/home/ikus060/workspace/PDSL/rdiffweb.git/.venv/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 56, in __init__
    super().__init__(
  File "/home/ikus060/workspace/PDSL/rdiffweb.git/.venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 206, in __init__
    self.start_session(capabilities)
  File "/home/ikus060/workspace/PDSL/rdiffweb.git/.venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 290, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
  File "/home/ikus060/workspace/PDSL/rdiffweb.git/.venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 345, in execute
    self.error_handler.check_response(response)
  File "/home/ikus060/workspace/PDSL/rdiffweb.git/.venv/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /home/ikus060/.cache/selenium/chrome/linux64/115.0.5790.102/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Stacktrace:
#0 0x55afbf2ddb13 <unknown>
#1 0x55afbf01d277 <unknown>
#2 0x55afbf047b88 <unknown>
#3 0x55afbf0444de <unknown>
#4 0x55afbf083f32 <unknown>
#5 0x55afbf08368f <unknown>
#6 0x55afbf07b1d3 <unknown>
#7 0x55afbf04f632 <unknown>
#8 0x55afbf0503de <unknown>
#9 0x55afbf2a297d <unknown>
#10 0x55afbf2a7213 <unknown>
#11 0x55afbf2b0628 <unknown>
#12 0x55afbf2a7c4a <unknown>
#13 0x55afbf2792ae <unknown>
#14 0x55afbf2c86d8 <unknown>
#15 0x55afbf2c887f <unknown>
#16 0x55afbf2d7098 <unknown>
#17 0x7f8c71cfbb43 <unknown>

Operating System

Ubuntu Linux 64bits

Selenium version

=4.11.0

What are the browser(s) and version(s) where you see this issue?

Chromium 115.0.5790.102 snap

What are the browser driver(s) and version(s) where you see this issue?

Not sure

Are you using Selenium Grid?

No

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 25 (15 by maintainers)

Most upvoted comments

Currently, the warning is shown when the driver in PATH is strictly different from the recommended driver. This is your case (you have chromedriver 111.0.5563.146, and the recommended version is 111.0.5563.64). But typically, you don’t need to worry since the major version (111) matches. So we have changed the Selenium Manager logic to show only the warning message when the major version is different.

Ah, I didn’t read your post closely enough. The warning is because Selenium is looking for the latest version of a released chromedriver (*.64), but you aren’t using a released chromedriver, rather a built driver from chromium, so Selenium is throwing a warning that it isn’t what it expects. We could do more complicated logic here, but I think Boni already merged a commit so that it isn’t as strict about the patch version.

I’m saying it should also check for an installed CfT

SM already checks CfT releases on the cache before downloading a new one.

and an installed Chromium

That is what I said above it is not implemented (see my first post in this thread).

As recommended, to support selenium <=4.10 and selenium>=4.11, I used the following code:

        # for selenium >=4.11, explicitly define location of chronium driver.
        if hasattr(webdriver, 'ChromeService'):
            chrome_service_cls = getattr(webdriver, 'ChromeService')
            service = chrome_service_cls(executable_path=shutil.which('chromedriver'))
        else:
            service = None
        driver = webdriver.Chrome(options=options, service=service)

This effectively skip selenium-manager, use the chromedriver from the PATH and automatically find chronium web browser.