You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修复Python Selenium WebDriver中Chrome版本不匹配引发的SessionNotCreatedException错误

Fixing ChromeDriver SessionNotCreatedException Mismatch Error

Got it, let's fix this version mismatch issue step by step—you're already halfway there by downloading the ChromeDriver that matches your Chrome 100.0.4896.75 version. Here's exactly what to do next:

Step 1: Locate your downloaded ChromeDriver

Find the chromedriver.exe file you extracted from the zip. For better organization, I recommend moving it to a dedicated folder in your Python project (like a drivers subfolder) so you can easily reference it later.

Step 2: Update your Selenium code to use the correct driver

You have two straightforward options here:

Option 1: Add ChromeDriver to your system PATH (one-time setup)

  • On Windows, right-click "This PC" > "Properties" > "Advanced system settings" > "Environment Variables".
  • Under "System variables", find the Path variable, click "Edit".
  • Click "New" and paste the full folder path where your chromedriver.exe is stored (just the folder, not the .exe file itself).
  • Save all changes and restart your command prompt or IDE—this ensures the PATH update takes effect.

Once done, your existing Selenium code will work without extra path configuration:

from selenium import webdriver

# Initialize the driver and open your target URL
driver = webdriver.Chrome()
driver.get("your-target-url-here")

# Your existing login/element click logic goes here
# Example: Fill username field
username = driver.find_element_by_id("username")
username.send_keys("your-username")

Option 2: Specify the ChromeDriver path directly in your code

If you don't want to modify system settings, you can point Selenium straight to the driver file in your script:

from selenium import webdriver

# Replace this with the actual path to your chromedriver.exe
driver_path = r"C:\your-project-folder\drivers\chromedriver.exe"
driver = webdriver.Chrome(executable_path=driver_path)
driver.get("your-target-url-here")

# Sample element interaction (adjust to your site's elements)
password = driver.find_element_by_name("password")
password.send_keys("your-password")
login_btn = driver.find_element_by_xpath("//button[text()='Log In']")
login_btn.click()

Step 3: Verify the fix

Run your script again—you should no longer see the SessionNotCreatedException error. If it still appears, double-check:

  • That your ChromeDriver version exactly matches your Chrome browser version (confirm Chrome's version via chrome://settings/help).
  • That the path to chromedriver.exe (either in PATH or your code) is free of typos, and the file exists in that location.

Quick note on the webbrowser library

You mentioned trying webbrowser earlier—this library is great for simple browser launches, but it doesn't support any page element interactions (like filling forms or clicking buttons). That's why Selenium is still the right tool for your specific use case.

内容的提问来源于stack exchange,提问作者MayMoshe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 18:02:42