Summary
A Selenium test failed because ChromeDriver 146 was used against Chrome 145. The mismatch prevented the driver from establishing a session, resulting in a SessionNotCreatedException.
Root Cause
- Version incompatibility between Chrome browser and ChromeDriver.
- ChromeDriver is tightly coupled to a specific major Chrome version; it rejects connections to older browsers.
- The developer was manually downloading the latest driver without checking the installed browser version.
Why This Happens in Real Systems
- Chrome auto‑updates on some machines but not on others (policy, corporate firewalls, or user settings).
- Teams often pin a driver version in CI pipelines; when a browser is upgraded independently, the pin becomes stale.
- Selenium’s error message is precise but can be overlooked by newcomers who focus on the stack trace instead of the version numbers.
Real-World Impact
- Test suites stop running in CI/CD pipelines, causing blocked releases.
- Debug time increases as engineers chase log lines that appear unrelated to version numbers.
- Customer‑facing automation (e.g., UI health checks) fails, potentially triggering false alarms.
Example or Code (if necessary and relevant)
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
service = Service(executable_path="/path/to/chromedriver")
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(service=service, options=options)
driver.get("https://example.com")
print(driver.title)
driver.quit()
The code itself is correct; the failure stems solely from the driver‑browser version mismatch.
How Senior Engineers Fix It
- Pin matching versions in a configuration file or environment variable.
- Automate driver download using tools like
webdriver-managerorplaywrightthat sync versions. - Add a pre‑run sanity check:
- Query Chrome version (
chrome://version/orgoogle-chrome --version). - Compare with ChromeDriver’s
--versionoutput. - Abort with a clear error if they differ.
- Query Chrome version (
- Keep browser updates under control in production/staging environments (e.g., use a locked Chrome version Docker image).
Why Juniors Miss It
- Tend to read the stack trace and assume a code bug, ignoring the version numbers highlighted in the exception.
- May not be familiar with the tight coupling between ChromeDriver and Chrome versions.
- Often lack experience with environment consistency practices (pinning, CI checks, automated driver management).