[英]Selenium program throws compilation error org.openqa.selenium.internal.Killable cannot be resolved
I've created a new Java project using Selenium and Maven.我使用 Selenium 和 Maven 创建了一个新的 Java 项目。 This is the relevant content in pom.xml这是pom.xml中的相关内容
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.45.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>
I then created this basic Java program that uses Selenium framework:然后我创建了这个使用 Selenium 框架的基本 Java 程序:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Start {
public static void main(String[] args) {
// declaration and instantiation of objects/variables
System.setProperty("webdriver.firefox.marionette", "D:\\geckodriver.exe");
WebDriver driver = null;
try {
driver = new FirefoxDriver();
String baseUrl = "https://www.google.co.in/";
driver.get(baseUrl);
} finally {
driver.close();
}
}
}
However, I'm getting this compilation error:但是,我收到此编译错误:
The type org.openqa.selenium.internal.Killable cannot be resolved.无法解析 org.openqa.selenium.internal.Killable 类型。 It is indirectly referenced from required .class files它是从所需的 .class 文件间接引用的
Can someone pls suggest where am I going wrong?有人可以建议我哪里出错了吗?
Remove this dependency from pom.xml
:从pom.xml
删除此依赖项:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.8.1</version>
</dependency>
You are using a vesrion 2.45.0 of Selenium java bindings (published on February 2015):您正在使用 Selenium java 绑定的 vesrion 2.45.0(2015 年 2 月发布):
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.45.0</version>
</dependency>
If you examine compile dependencies of the above package: https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java/2.45.0如果您检查上述包的编译依赖项: https : //mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java/2.45.0
you will see that this package depends on selenium-chrome-driver 2.45.0
package.你会看到这个包依赖于selenium-chrome-driver 2.45.0
包。 Maven will resolve this dependency automatically during compilation, so you don't need to declare this package in the pom.xml
. Maven 会在编译时自动解析这个依赖,所以你不需要在pom.xml
声明这个包。 file.文件。
But if you declare this package selenium-chrome-driver
as a dependency directly in the pom.xml
file, using different version (the newest 3.8.1
), then maven will be using this version 3.8.1
instead of 2.45.0
during compilation, and this will cause the error - wrong, incompatibile jar library is used.但是如果你直接在pom.xml
文件中声明这个包selenium-chrome-driver
作为依赖,使用不同的版本(最新的3.8.1
),那么 maven 在编译过程中将使用这个版本3.8.1
而不是2.45.0
,这将导致错误 - 错误,使用了不兼容的 jar 库。
请检查您的 POM.XMl 文件,您可能有两个不同版本的“selenium-java”或“selenium-chrome-driver”依赖项。
I also got same error.我也遇到了同样的错误。 If you want to resolve this, follow these steps:如果要解决此问题,请按照下列步骤操作:
pom.xml
转到pom.xml
的路径位置Give access to
右键单击并选择Give access to
Remove access
点击Remove access
Change sharing permission
点击Change sharing permission
Everyone
在下拉菜单中,选择Everyone
Permission level
, choose Read/Write
对于Permission level
,选择Read/Write
XML
file.保存XML
文件。It should work now.它现在应该可以工作了。
add this dependency:添加此依赖项:
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.12.0</version>
</dependency>
Add the following dependencies添加以下依赖项
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>3.14.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.14.0</version>
<scope>test</scope>
</dependency>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.