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

Python使用webbot时Selenium chromedriver版本不匹配报错排查

macOS下webbot调用抛出SessionNotCreatedException问题解决

问题现象

环境信息:

  • 系统:macOS(为运行32位软件固定使用10.14版本,对应报错中平台标识为Mac OS X 10.14.6 x86_64)
  • Python版本:3.9
  • Selenium版本:4.3.0
  • 系统已安装chromedriver版本:103.0.5060.53,安装路径/usr/local/bin/

调用webbot库启动浏览器时固定抛出如下错误:

selenium.common.exceptions.SessionNotCreatedException: Message: session not created 
exception: Missing or invalid capabilities
  (Driver info: chromedriver=2.39.562713 
(dd642283e958a93ebf6891600db055f1f1b4f3b2),platform=Mac OS X 10.14.6 x86_64)

异常特征:

  • 报错信息显示调用的chromedriver版本为2.39.562713,和系统安装的103版本不符
  • 直接使用原生selenium代码启动Chrome可正常运行,说明Chrome、系统级chromedriver、selenium的基础配置无问题:
from selenium import webdriver
driver = webdriver.Chrome()
  • 尝试按照旧版webbot的用法,在构造Browser对象时传入系统chromedriver所在路径,报错无任何变化:
from webbot import Browser
driver = Browser(True, None, '/usr/local/bin/')

根因定位

排查当前安装版本webbot的源码确认问题来源:

  1. 最新版webbot的Browser类构造函数签名已经变更,旧版支持的driverPath参数已被移除,因此传入路径的操作完全不生效,当前构造函数定义如下:
def __init__(self, showWindow=True, proxy=None , downloadPath:str=None):
  1. 在构造方法内部打印内置的driverpath变量,确认webbot实际加载的驱动路径为包内自带文件:
project_root/virtualenvironment/lib/python3.9/site-packages/webbot/drivers/chrome_mac
  1. 该自带驱动版本为2.39,和4.3.0版本selenium的能力校验规则不兼容,是触发Missing or invalid capabilities报错的根本原因——webbot不会调用系统安装的新版chromedriver,只会强制使用包内捆绑的旧版本驱动。

解决步骤

  1. 定位到webbot安装目录下的drivers/chrome_mac文件,将其重命名备份(例如重命名为chrome_mac_bak)
  2. 在原chrome_mac路径下创建软链接,指向系统中安装的、与当前Chrome版本匹配的chromedriver二进制文件(即/usr/local/bin/chromedriver)
  3. 重新运行webbot启动代码,浏览器可正常拉起,报错消失。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.29 05:18:19