我正在尝试编写代码(Java、Selenium)来连接到 DevTools。 在 devTools.createSession() 行,我看到错误:
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.
我知道版本 9.2.63.1 的 chrome 不存在,但我的自定义浏览器版本是 9.2.63.1。
在“关于浏览器”窗口中我可以看到:
版本:9.2.63.1 核心:116.0.5845.110
我知道“core”是 chrome 的版本,但 CdpVersionFinder 采用的版本不正确。
我找到了很多解决方案并尝试了所有这些,但这对我没有帮助。
我无法安装新版本的浏览器,不幸的是无法在其中传递大量代码。
我成功解决了这个问题。我重写了为 chrome 驱动程序切换 cdp 版本的类。在新课程中,我编写了我需要的浏览器版本,并且运行良好。 文档:https://www.geeksforgeeks.org/overriding-in-java/amp/