CdpVersionFinder错误识别Chromium内核浏览器版本问题求助
问题:Selenium连接自定义Chromium内核浏览器DevTools时版本匹配错误
错误信息
org.openqa.selenium.devtools.DevToolsException: You are using a no-op implementation of the CDP. The most likely reason for this is that Selenium was unable to find an implementation of the CDP protocol that matches your browser. Please be sure to include an implementation on the classpath, possibly by adding a new (maven) dependency of `org.seleniumhq.selenium:selenium-devtools-vNN:4.14.0` where `NN` matches the major version of the browser you're using. Build info: version: '4.14.0', revision: 'e5a96349ce' System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '22' Driver info: DevTools Connection
控制台警告
апр. 04, 2024 1:07:55 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch WARNING: Unable to find CDP implementation matching 9 апр. 04, 2024 1:07:55 PM org.openqa.selenium.chromium.ChromiumDriver lambda$new$5 WARNING: Unable to find version of CDP to use for 9.2.63.1. You may need to include a dependency on a specific version of the CDP using something similar to `org.seleniumhq.selenium:selenium-devtools-v86:4.14.0` where the version ("v86") matches the version of the chromium-based browser you're using and the version number of the artifact is the same as Selenium's.
浏览器版本情况
自定义浏览器的实际版本信息:
Version: 9.2.63.1 Core: 116.0.5845.110
浏览器内核为Chrome 116,但Selenium的CdpVersionFinder错误识别了浏览器主版本为9,导致CDP协议不匹配。
已尝试无效方案
- 导入
selenium-devtools-vVERSION:4.14.0依赖 - 更换其他版本的Selenium
- 通过chromeOptions修改浏览器版本(不可行)
解决方案
1. 手动指定CDP版本
初始化DevTools时强制设置对应内核的版本号:
// 假设已完成driver初始化 DevTools devTools = ((HasDevTools) driver).getDevTools(); // 强制指定CDP版本为内核对应的116 devTools.setVersion(116); devTools.createSession();
2. 添加对应版本的DevTools依赖
确保项目依赖中包含Chrome 116对应的DevTools包(以Maven为例):
<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-devtools-v116</artifactId> <version>4.14.0</version> </dependency>
3. 自定义版本查找逻辑
如果前两种方法无效,可在驱动初始化前替换默认的版本查找逻辑:
CdpVersionFinder.setInstance(new CdpVersionFinder() { @Override public int findNearestMatch(int browserMajorVersion) { // 直接返回内核主版本116 return 116; } });
内容的提问来源于stack exchange,提问作者Brenker
相关产品推荐
相关产品推荐

