我正在尝试让 Selenium 与 Java 一起工作。我正在使用 Maven。我的 pom.xml 文件看起来像这样
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.1.2</version>
</dependency>
当我尝试运行我的程序时,出现以下错误。 Chrome 启动但未打开任何网站。我试过 chrome webdriver 版本 98、97 和 96。我的正常 chrome 版本重要吗?
Starting ChromeDriver 97.0.4692.71 (adefa7837d02a07a604c1e6eff0b3a09422ab88d-refs/branch-heads/4692@{#1247}) on port 61659
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
[1644353402.048][WARNING]: This version of ChromeDriver has not been tested with Chrome version 98.
Feb. 08, 2022 9:50:02 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Feb. 08, 2022 9:50:02 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
WARNING: Unable to find an exact match for CDP version 98, so returning the closest version found: 97
Feb. 08, 2022 9:50:02 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
INFO: Found CDP implementation for version 98 of 97
最佳答案
遗憾的是,Selenium 4.1.2 还不支持 v98。这是变更日志:
v4.1.2
- Supported CDP versions: 85, 95, 96, 97
- Add new desktop cast command for Chromium
- ...
这并不意味着它不会工作,但在我的情况下,它工作得很好。但是,是的,您可能会遇到一些无法正常工作的情况。
关于java - Selenium Chromedriver : Unable to find an exact match for CDP version 98, 所以返回找到的最接近的版本:97,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71040802/