0
0
Selenium-pythonDebug / FixBeginner · 4 min read

How to Fix 'Session Not Created' Error in Selenium

The session not created error in Selenium happens when the browser driver version does not match the installed browser version. To fix it, update your browser driver (like chromedriver) to the version compatible with your browser and ensure both are up to date.
🔍

Why This Happens

This error occurs because Selenium tries to start a browser session using a driver that does not support the installed browser version. For example, if your Chrome browser updated but your chromedriver is old, Selenium cannot create a session.

python
from selenium import webdriver

# Using old chromedriver with new Chrome browser
driver = webdriver.Chrome(executable_path='path/to/old/chromedriver')
driver.get('https://example.com')
Output
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 90 Current browser version is 114.0.5735.199 with binary path /usr/bin/google-chrome
🔧

The Fix

Update your browser driver to match your browser version. For Chrome, download the latest chromedriver from the official site that supports your Chrome version. Then, use the updated driver path in your Selenium code.

python
from selenium import webdriver
from selenium.webdriver.chrome.service import Service

service = Service('path/to/updated/chromedriver')
driver = webdriver.Chrome(service=service)
driver.get('https://example.com')
print('Browser opened successfully')
driver.quit()
Output
Browser opened successfully
🛡️

Prevention

To avoid this error in the future, always keep your browser and driver versions in sync. Use tools or scripts to check driver compatibility automatically. Consider using WebDriver managers that download the correct driver version for you.

  • Regularly update browsers and drivers.
  • Use WebDriver manager libraries like webdriver-manager in Python or Java.
  • Test driver compatibility after browser updates.
⚠️

Related Errors

Other common errors include:

  • Driver executable needs to be in PATH: Selenium cannot find the driver file.
  • Timeout errors: Caused by slow browser startup or network issues.
  • Version mismatch warnings: When driver and browser versions differ slightly.

Fixes usually involve setting correct driver paths, updating drivers, or increasing timeouts.

Key Takeaways

Always match your browser driver version with your browser version to avoid session errors.
Update drivers immediately after browser updates to keep Selenium working smoothly.
Use WebDriver manager tools to automate driver version management.
Check error messages carefully to identify version mismatches or missing drivers.
Test your setup after updates to catch compatibility issues early.