【问题标题】:Error: java: cannot access org.openqa.selenium.HasInputDevices class file for org.openqa.selenium.HasInputDevices not found错误:java:无法访问 org.openqa.selenium.HasInputDevices 的 org.openqa.selenium.HasInputDevices 类文件未找到
【发布时间】:2014-11-14 10:51:30
【问题描述】:

我正在尝试通过 Maven 运行我的用户接受测试用例 (JBehave),但出现此错误:

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

下面展示了用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>

请找出原因及其解决方案。如果你们需要有关该项目的更多信息,请告诉我。

【问题讨论】:

    标签: java maven selenium jbehave


    【解决方案1】:

    听起来像是传递依赖问题。检查this SO post 是否有类似情况。我建议在您的项目上生成一个依赖关系图并检查被拉入的selenium-java 的版本。根据依赖关系图的结果设置您的排除项。

    【讨论】:

      【解决方案2】:

      我遇到了类似的问题,我使用以下依赖项解决了它。 但这只是在我使用 HTML 单元驱动程序时。下面的组合效果很好。

              <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>
      

      【讨论】:

        猜你喜欢
        • 2018-07-20
        • 2019-06-22
        • 2017-10-16
        • 1970-01-01
        • 1970-01-01
        • 2019-05-24
        • 2017-06-09
        • 2019-05-03
        • 2019-02-10
        相关资源
        最近更新 更多