Home > Mobile >  Selenium 4.0.x works in IDE but not in fat JAR file - a CDP implementation for my browser version ca
Selenium 4.0.x works in IDE but not in fat JAR file - a CDP implementation for my browser version ca

Time:10-06

When running a selenium test in the Eclipse IDE, the test works fine, but after building a fat JAR with Maven and running from the command line, Selenium reports a warning that no CDP implementation for the browser version I'm using can be found and thus a "no-op" implementation is being used.

CodePudding user response:

This occurs either due to the classpath being incorrect (hard to get wrong with a JAR that's supposed to contain all dependencies) or due to classes missing from the fat JAR that are discovered as implementations of interfaces at runtime.

There's a standalone Selenium zip file containing a bunch of JAR files that can be downloaded here: https://www.selenium.dev/downloads/

I downloaded and inspected that zip file to see which JARs it contains and then added the selenium related ones to my Maven dependencies as shown below. After rebuilding the fat JAR with these dependencies, the program works as expected.

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-api</artifactId>
        <version>4.0.0-rc-2</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-chrome-driver</artifactId>
        <version>4.0.0-rc-2</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-chromium-driver</artifactId>
        <version>4.0.0-rc-2</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-devtools-v94</artifactId>
        <version>4.0.0-rc-2</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-http</artifactId>
        <version>4.0.0-rc-2</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>4.0.0-rc-2</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-json</artifactId>
        <version>4.0.0-rc-2</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-remote-driver</artifactId>
        <version>4.0.0-rc-2</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-support</artifactId>
        <version>4.0.0-rc-2</version>
    </dependency>

CodePudding user response:

If you are working on local and jenkins execution, please add following dependency. this is enough for your code.

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.141.59</version>
</dependency>

those RC related JARs are only useful when you are setting up Selenium grid and parallel execution process.

  • Related