python system_error ai_generated true

selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 120 Current browser version is 124.0.6367.78

ID: python/pytest-selenium-webdriver-not-found

Also available as: JSON · Markdown · 中文
80%Fix Rate
87%Confidence
0Evidence
2024-04-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
4.18 active

Root Cause

ChromeDriver binary version does not match the installed Chrome browser version. Selenium 4.x auto-manages drivers via Selenium Manager, but a stale chromedriver on PATH takes precedence and causes the mismatch.

generic

中文

ChromeDriver 二进制版本与已安装的 Chrome 浏览器版本不匹配。Selenium 4.x 通过 Selenium Manager 自动管理驱动,但 PATH 上过时的 chromedriver 会优先使用并导致不匹配。

Workarounds

  1. 95% success
    which chromedriver && sudo rm $(which chromedriver)
    pytest tests/e2e/ -v
    # Selenium Manager downloads the correct driver on first run
  2. 90% success
    # Dockerfile
    RUN apt-get install -y google-chrome-stable=124.* 
    # or use selenium/standalone-chrome:124.0 image
    # pytest with RemoteWebDriver pointing to the container

Dead Ends

Common approaches that don't work:

  1. 85% fail

    Security risk and often blocked by corporate IT; also brittle since Chrome auto-updates.

  2. 90% fail

    Headless still launches a real Chrome binary; the version check happens before mode selection.