0

I have been trying to install Selenium for about a day now, and I can´t get it to work. First, I just downloaded the standalone jar and added it as a user library. That did work out fine, until I wanted to use org.openqa.selenium.htmlunit.HtmlUnitDriver. Apparently, this library is not included in the jar. So I downloaded the jar file for the htmlUnitDriver seperately. That did not work out at all, as I got an error in line 1 saying, that some library is "indirectly referenced from required .class files". I deinstalled the libraries again and tried it with Maven. I included dependencies for selenium and the selenium htmlUnitDriver (as it again was not included). But that still left me with the same problem. Below is my pom.xml file and the exact error message.

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <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-htmlunit-driver</artifactId>
            <version>2.52.0</version>
        </dependency>
    </dependencies>
    <modelVersion>4.0.0</modelVersion>
    <groupId>WebsiteRequest</groupId>
    <artifactId>WebsiteRequest</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <release>12</release>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

The java code:

package pack;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

public class Klasse  {

    public static void main(String[] args) {
        
        WebDriver driver = new HtmlUnitDriver();

    }
}

The error message: Error Message

I have noticed, that the error only occurs, when I initialise a WebDriver as a HtmlUnitDriver. Otherwise it is still shown, but not marked as an error: The other variant of the error message

4
  • Is that a complete pom.xml? I do not have such issue with your pom. Also have you tried to do clean before compile? Commented Oct 1, 2021 at 7:14
  • @Alexey R. Oh I forgot to mention… The error occurs when I try to work with the library. It then shows the error message in the first line, where you mention the package. Commented Oct 1, 2021 at 11:15
  • Can you show the example of the code? Commented Oct 1, 2021 at 11:29
  • @AlexeyR. I have added the code, as well as two screenshots and some additional information (not much though). Commented Oct 1, 2021 at 14:52

1 Answer 1

1

There was a change one year ago which removes a list of interfaces. Those interfaces are used (implemented) by HtmlUnitDriver. The change was delivered in selenium-4.0.0-alpha-7 release.

So the solution would be to use Selenium release prior to mentioned one.

Either: (this is not stable version with some features of Selenium 4)

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>4.0.0-alpha-6</version>
</dependency>

Or:

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.141.59</version>
</dependency>

The latter is the most stable and recent version of Selenium 3.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.