Home > database >  Java - Selenium - Unable to find an exact match for CDP version 94, so returning the closest version
Java - Selenium - Unable to find an exact match for CDP version 94, so returning the closest version

Time:10-08

I'm new to Selenium and I'm having an error about CDP versions when running my code. This is my code. It's simple, aiming to log in into some web page. The driver opens, fills the email and password but when reaching the button, the driver closes. 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("[email protected]");
                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

    <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. Thanks in advance!

CodePudding user response:

As per Selenium documentation,

  • The version v4.0.0-rc-1 supports CDP versions: 85, 92, 93.

But you are using 94 version of Chrome and ChromeDriver. So please update your dependencies to latest version 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

  • Related