"error: cannot access Killable" while compiling the code with selenium java 3.11 libraries
"error: cannot access Killable" while compiling the code with selenium java 3.11 libraries
代码编译失败,第 "error: cannot access Killable" 行
class FirefoxWebDriver 扩展了 FirefoxDriver{
......
我们已经从 3.3.1 升级到 Selenium 3.11。我们正在尝试 运行 使用 Docker 在配置了 selenium 网格的浏览器上进行测试。我发现 Killable class 被删除了。请建议我是否需要更新任何代码变更。
谢谢。
如果没有您的 Project Setup 信息(即您正在使用 Selenium JARs,Ant、Maven 或 Gradle),您的 代码试验 和 错误堆栈跟踪 。
但是这个错误信息...
error: cannot access Killable
...表示您的程序在访问 Killable.
时遇到错误
Killable.class 文件
根据讨论 Killable ClassNotFound the Killable.class file was contained in 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 或 [=149= 形式使用的二进制文件之间存在冲突 ] 依赖性,并且可能是由于 存在 或 one/multiple 如下:
- 硒服务器 2.21.0.jar
- 硒-api-2.21.0.jar
- selenium-server 2.21.0 或 selenium-api-2.21 的 Maven 依赖项。 0
- Gradle selenium-server 2.21.0 或 selenium-[=155= 的依赖关系 ]-2.21.0
解决方案
如果您正在使用 Selenium Java Jars 下载并添加相应的 jar/jars (来自):
- selenium-server-standalone-3.11.0.jar
- 硒-java-3.11.0.zip
如果您正在使用 Selenium 的 Maven 依赖项,请使用以下任一方法:
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
代码编译失败,第 "error: cannot access Killable" 行 class FirefoxWebDriver 扩展了 FirefoxDriver{ ......
我们已经从 3.3.1 升级到 Selenium 3.11。我们正在尝试 运行 使用 Docker 在配置了 selenium 网格的浏览器上进行测试。我发现 Killable class 被删除了。请建议我是否需要更新任何代码变更。
谢谢。
如果没有您的 Project Setup 信息(即您正在使用 Selenium JARs,Ant、Maven 或 Gradle),您的 代码试验 和 错误堆栈跟踪 。
但是这个错误信息...
error: cannot access Killable
...表示您的程序在访问 Killable.
时遇到错误Killable.class 文件
根据讨论 Killable ClassNotFound the Killable.class file was contained in 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 或 [=149= 形式使用的二进制文件之间存在冲突 ] 依赖性,并且可能是由于 存在 或 one/multiple 如下:
- 硒服务器 2.21.0.jar
- 硒-api-2.21.0.jar
- selenium-server 2.21.0 或 selenium-api-2.21 的 Maven 依赖项。 0
- Gradle selenium-server 2.21.0 或 selenium-[=155= 的依赖关系 ]-2.21.0
解决方案
如果您正在使用 Selenium Java Jars 下载并添加相应的 jar/jars (来自):
- selenium-server-standalone-3.11.0.jar
- 硒-java-3.11.0.zip
如果您正在使用 Selenium 的 Maven 依赖项,请使用以下任一方法:
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