I am trying to run my user-acceptance test cases (JBehave) via Maven but i am getting this error:

Error:(10, 8) java: cannot access org.openqa.selenium.HasInputDevices class file for org.openqa.selenium.HasInputDevices not found

Following shows the dependencies of the project written in Maven.

    <dependency>
        <groupId>org.jbehave</groupId>
        <artifactId>jbehave-core</artifactId>
        <version>${jbehave.core.version}</version>
    </dependency>
    <dependency>
        <groupId>org.jbehave</groupId>
        <artifactId>jbehave-core</artifactId>
        <version>${jbehave.core.version}</version>
        <classifier>resources</classifier>
        <type>zip</type>
    </dependency>
    <dependency>
        <groupId>org.jbehave.site</groupId>
        <artifactId>jbehave-site-resources</artifactId>
        <version>${jbehave.site.version}</version>
        <type>zip</type>
    </dependency>
    <dependency>
        <groupId>org.jbehave.web</groupId>
        <artifactId>jbehave-web-selenium</artifactId>
        <version>${jbehave.web.version}</version>
        <!--
        <exclusions>
            <exclusion>
                <groupId>org.jbehave</groupId>
                <artifactId>jbehave-core</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-java</artifactId>
            </exclusion>
        </exclusions>
        -->
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium.fluent</groupId>
        <artifactId>fluent-selenium</artifactId>
        <version>${fluent.selenium.version}</version>
        <optional>true</optional>
        <!--
        <exclusions>
            <exclusion>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-java</artifactId>
            </exclusion>
        </exclusions>
        -->
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit-dep</artifactId>
        <version>4.8.2</version>
        <!--
        <exclusions>
            <exclusion>
                <groupId>org.hamcrest</groupId>
                <artifactId>hamcrest-core</artifactId>
            </exclusion>
        </exclusions>
        -->
    </dependency>
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-all</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>${selenium.version}</version>
        <!--
        <exclusions>
            <exclusion>
                <groupId>org.hamcrest</groupId>
                <artifactId>hamcrest-core</artifactId>
            </exclusion>
        </exclusions>
        -->
    </dependency>
    <dependency>
        <groupId>org.jbehave</groupId>
        <artifactId>jbehave-spring</artifactId>
        <version>${jbehave.core.version}</version>
    </dependency>

Please kindly figure out causes and their solutions. If you guys need more information about the project, please kindly let me know.

2

There are 2 answers

0
shri046 On

Sounds like a transitive dependency issue. Check this SO post for a similar. I would suggest generating a dependency graph on your project and check the version of selenium-java being pulled in. Setup your exclusions based on the findings from the dependency graph.

0
Linus On

I had a similar issue and i resolved it with the below dependencies. But this was only when i was using HTML Unit driver. The below combination works well.

        <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.14.0</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-htmlunit-driver</artifactId>
        <version>2.52.0</version>
    </dependency>