【问题标题】:"error: cannot access Killable" while compiling the code with selenium java 3.11 libraries使用 selenium java 3.11 库编译代码时出现“错误:无法访问 Killable”
【发布时间】:2018-11-18 22:21:48
【问题描述】:

代码编译失败并在该行显示“错误:无法访问 Killable” 类 FirefoxWebDriver 扩展 FirefoxDriver{ ......

我们已从 3.3.1 升级到 Selenium 3.11。我们正在尝试使用 Docker 在配置有 selenium 网格的浏览器上运行测试。我发现 Killable 类已被删除。请建议我是否需要更新任何代码更改。

谢谢。

【问题讨论】:

  • at the line class FirefoxWebDriver extends FirefoxDriver 和 tests on chrome browser ... 你可以交叉检查吗?
  • 我们有每个驱动程序(chrome、firefox)的代码。运行测试时,Firefox 驱动程序的代码编译失败。

标签: selenium selenium-webdriver webdriver selenium-firefoxdriver geckodriver


【解决方案1】:

如果没有您的项目设置信息(即您正在使用Selenium JAR、Ant、Maven),很难分析/得出结论 或 Gradle),您的代码试验和错误堆栈跟踪。

但是这个错误信息...

error: cannot access Killable

...表示您的程序在访问 Killable 时遇到错误。

Killable.class 文件

根据Killable ClassNotFound 的讨论,Killable.class 文件包含在selenium-api-2.21.0.jar 中。此外,使用 selenium-server 2.21.0 的 Maven 依赖项 会产生错误:

Exception in thread "main" java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/openqa/selenium/internal/Killable

说明

正如您所提到的,您已从 Selenium 3.3.1 升级到 Selenium 3.11,可能的原因是您所使用的二进制文件之间存在版本冲突以 JARs、Maven 或 Gradle 依赖的形式使用,并且可能是由于 存在 的一个/多个其中:

  • 硒服务器 2.21.0.jar
  • selenium-api-2.21.0.jar
  • selenium-server 2.21.0 或 selenium-api-2.21.0 的 Maven 依赖项
  • selenium-server 2.21.0 或 selenium-api-2.21.0 的 Gradle 依赖项

解决方案

  • 如果您使用的是 Selenium Java Jars,请下载并添加相应的 jar/jars(来自):

    • selenium-server-standalone-3.11.0.jar
    • selenium-java-3.11.0.zip
  • 如果您使用 Maven 对 Selenium 的依赖项,请使用以下任一选项:

    • Selenium Java 客户端依赖:

      <dependency>
          <groupId>org.seleniumhq.selenium</groupId>
          <artifactId>selenium-java</artifactId>
          <version>3.11.0</version>
      </dependency>   
      
    • Selenium 服务器依赖:

      <dependency>
          <groupId>org.seleniumhq.selenium</groupId>
          <artifactId>selenium-server</artifactId>
          <version>3.11.0</version>
      </dependency> 
      

琐事

如果您使用的是 Maven,您可以在您的 root pom 中添加此块(在构建部分中,只需添加到插件中)来解决您使用的不同版本的二进制文件得到了。

<build>
    <plugins>
    <plugin>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>1.0</version>
        <executions>
        <execution>
            <id>enforce</id>
            <goals>
            <goal>enforce</goal>
            </goals>
            <configuration>
            <rules>
                <DependencyConvergence />
            </rules>
            </configuration>
        </execution>
        </executions>
    </plugin>
    </plugins>
</build>

供您参考selenium-server 2.21.0输出树如下:

[INFO] \- org.seleniumhq.selenium:selenium-server:jar:2.21.0:compile
[INFO]    +- org.bouncycastle:bcprov-jdk15on:jar:1.47:compile
[INFO]    +- mx4j:mx4j-tools:jar:3.0.1:compile
[INFO]    +- org.mortbay.jetty:servlet-api-2.5:jar:6.1.9:compile
[INFO]    +- org.seleniumhq.selenium:jetty-repacked:jar:7.6.1:compile
[INFO]    +- net.jcip:jcip-annotations:jar:1.0:compile
[INFO]    +- org.seleniumhq.selenium:selenium-java:jar:2.21.0:compile
[INFO]    |  +- org.seleniumhq.selenium:selenium-android-driver:jar:2.21.0:compile
[INFO]    |  |  \- org.seleniumhq.selenium:selenium-remote-driver:jar:2.21.0:compile
[INFO]    |  |     +- cglib:cglib-nodep:jar:2.1_3:compile
[INFO]    |  |     +- org.json:json:jar:20080701:compile
[INFO]    |  |     \- com.google.guava:guava:jar:11.0.1:compile
[INFO]    |  |        \- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO]    |  +- org.seleniumhq.selenium:selenium-chrome-driver:jar:2.21.0:compile
[INFO]    |  +- org.seleniumhq.selenium:selenium-htmlunit-driver:jar:2.21.0:compile
[INFO]    |  |  +- org.seleniumhq.selenium:selenium-api:jar:2.21.0:compile
[INFO]    |  |  +- net.sourceforge.htmlunit:htmlunit:jar:2.9:compile
[INFO]    |  |  |  +- xalan:xalan:jar:2.7.1:compile
[INFO]    |  |  |  |  \- xalan:serializer:jar:2.7.1:compile
[INFO]    |  |  |  +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO]    |  |  |  +- commons-lang:commons-lang:jar:2.6:compile
[INFO]    |  |  |  +- org.apache.httpcomponents:httpmime:jar:4.1.2:compile
[INFO]    |  |  |  +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.9:compile
[INFO]    |  |  |  +- xerces:xercesImpl:jar:2.9.1:compile
[INFO]    |  |  |  |  \- xml-apis:xml-apis:jar:1.3.04:compile
[INFO]    |  |  |  +- net.sourceforge.nekohtml:nekohtml:jar:1.9.15:compile
[INFO]    |  |  |  +- net.sourceforge.cssparser:cssparser:jar:0.9.5:compile
[INFO]    |  |  |  |  \- org.w3c.css:sac:jar:1.3:compile
[INFO]    |  |  |  \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO]    |  |  \- org.apache.httpcomponents:httpclient:jar:4.1.2:compile
[INFO]    |  |     \- org.apache.httpcomponents:httpcore:jar:4.1.2:compile
[INFO]    |  +- org.seleniumhq.selenium:selenium-firefox-driver:jar:2.21.0:compile
[INFO]    |  |  +- commons-io:commons-io:jar:2.0.1:compile
[INFO]    |  |  \- org.apache.commons:commons-exec:jar:1.1:compile
[INFO]    |  +- org.seleniumhq.selenium:selenium-ie-driver:jar:2.21.0:compile
[INFO]    |  |  +- net.java.dev.jna:jna:jar:3.4.0:compile
[INFO]    |  |  \- net.java.dev.jna:platform:jar:3.4.0:compile
[INFO]    |  +- org.seleniumhq.selenium:selenium-iphone-driver:jar:2.21.0:compile
[INFO]    |  +- org.seleniumhq.selenium:selenium-safari-driver:jar:2.21.0:compile
[INFO]    |  +- org.seleniumhq.selenium:selenium-support:jar:2.21.0:compile
[INFO]    |  \- org.webbitserver:webbit:jar:0.4.6:compile
[INFO]    |     \- org.jboss.netty:netty:jar:3.2.7.Final:compile
[INFO]    +- org.yaml:snakeyaml:jar:1.8:compile
[INFO]    \- commons-codec:commons-codec:jar:1.6:compile

【讨论】:

  • 问题已解决,正如您所提到的,仍有一些引用指向旧版本的 selenium。通过清理这些引用,我们现在没有看到错误。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-22
  • 1970-01-01
  • 2014-10-17
  • 2019-04-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多