[英]Java - Selenium - Unable to find an exact match for CDP version 94, so returning the closest version found: 93
I'm new to Selenium and I'm having an error about CDP versions when running my code.我是 Selenium 的新手,在运行我的代码时遇到有关 CDP 版本的错误。 This is my code.这是我的代码。 It's simple, aiming to log in into some web page.很简单,旨在登录某个web页面。 The driver opens, fills the email and password but when reaching the button, the driver closes.驱动程序打开,填写 email 和密码,但当到达按钮时,驱动程序关闭。 Even if I set another wait for ten minutes after the button.即使我设置了另一个按钮后等待十分钟。
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","path/to/my/chromedriver");
WebDriver driver = new ChromeDriver();
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
try {
driver.get("https://someweb.com/");
driver.findElement(By.name("Email")).sendKeys("anemail@email.com");
driver.findElement(By.name("Password")).sendKeys("randomPass");
driver.findElement(By.xpath("//*[@id=\"login-form\"]/button")).sendKeys(Keys.ENTER);
} finally {
driver.quit();
}
}
I get the following warning in my log我在日志中收到以下警告
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Starting ChromeDriver 94.0.4606.61 (418b78f5838ed0b1c69bb4e51ea0252171854915-refs/branch-heads/4606@{#1204}) on port 44814
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
oct 06, 2021 9:45:02 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
oct 06, 2021 9:45:02 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
WARNING: Unable to find an exact match for CDP version 94, so returning the closest version found: 93
oct 06, 2021 9:45:02 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
INFO: Found CDP implementation for version 94 of 93
Process finished with exit code 0
And I have the following dependencies in my pom我的 pom 中有以下依赖项
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.0.0-rc-1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>4.0.0-rc-1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-devtools</artifactId>
<version>4.0.0-rc-1</version>
</dependency>
</dependencies>
I have no idea why the driver exits so suddenly.我不知道司机为什么突然下车。 Chrome and ChromeDriver version is 94.0.4606.61. Chrome 和 ChromeDriver 版本为 94.0.4606.61。 Thanks in advance!提前致谢!
As per Selenium
documentation,根据Selenium
文档,
v4.0.0-rc-1
supports CDP
versions: 85
, 92
, 93
.版本v4.0.0-rc-1
支持CDP
版本: 85
、 92
、 93
。 But you are using 94
version of Chrome
and ChromeDriver
.但是你使用的是94
版本的Chrome
和ChromeDriver
。 So please update your dependencies to latest version v4.0.0-rc-2
所以请将您的依赖项更新到最新版本v4.0.0-rc-2
Dependency :依赖性:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.0.0-rc-2</version>
</dependency>
Reference : https://github.com/SeleniumHQ/selenium/blob/trunk/java/CHANGELOG参考: https://github.com/SeleniumHQ/selenium/blob/trunk/java/CHANGELOG
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.