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

Chrome WebDriver 106出现uniqueContextId未找到异常求助

升级Chrome及WebDriver至106版本后出现uniqueContextId not found异常

问题描述

近期将Chrome及其WebDriver从103版本升级至106版本后,原本正常运行的代码开始抛出异常,错误信息如下:

OpenQA.Selenium.WebDriverException: invalid argument: uniqueContextId not found (Session info: chrome=106.0.5249.62)

异常抛出位置为:ExpectedConditions.ElementExists(loadingLocator)

ElementExist异常截图

解决方案建议

  • 严格匹配Chrome与ChromeDriver版本:Chrome 106对应的官方ChromeDriver版本是106.0.5249.61,务必下载该版本替换当前WebDriver,小版本不匹配极易引发兼容性问题。
  • 升级Selenium库:将Selenium.WebDriver包更新至4.5.0及以上稳定版,旧版Selenium对Chrome 106的支持存在已知缺陷,新版本已修复相关问题。
  • 替换过时的ExpectedConditions:Selenium 4.x中ExpectedConditions已被标记为弃用,推荐使用WebDriverWait结合Lambda表达式替代,示例代码:
new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(d => d.FindElement(loadingLocator) != null);
  • 排查Chrome启动参数:若代码中配置了自定义启动参数,尝试移除可能导致上下文冲突的参数(如--disable-site-isolation-trials)后重新测试。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.17 14:55:22