简体   繁体   English

Selenium 程序抛出编译错误 org.openqa.selenium.internal.Killable 无法解析

[英]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:如果要解决此问题,请按照下列步骤操作:

  1. Go to the path location of pom.xml转到pom.xml的路径位置
  2. Right-click and select Give access to右键单击并选择Give access to
  3. Click on Remove access点击Remove access
  4. Click on Change sharing permission点击Change sharing permission
  5. In the dropdown menu, select Everyone在下拉菜单中,选择Everyone
  6. For Permission level , choose Read/Write对于Permission level ,选择Read/Write
  7. Save the 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.

相关问题 无法解析“导入org.openqa.selenium.android.AndroidDriver” - The 'import org.openqa.selenium.android.AndroidDriver' cannot be resolved 导入org.openqa.selenium.firefox.FirefoxDriver无法解析 - The import org.openqa.selenium.firefox.FirefoxDriver cannot be resolved 导入 org.openqa.selenium.webdriver 无法解析 - the import org.openqa.selenium.webdriver cannot be resolved 无法将 WebElement 转换为 org.openqa.selenium.internal.Locatable - Cannot cast WebElement to org.openqa.selenium.internal.Locatable 构建错误:找不到 org.openqa.selenium.internal.Locatable 的类文件 - Build Error: Cannot find the class file for org.openqa.selenium.internal.Locatable Java - selenium 编译错误“无法解析为变量” - Java - selenium compilation error "cannot be resolved to a variable" 当元素可见且可单击时,Selenium Web驱动程序无法单击按钮,并引发org.openqa.selenium.ElementNotInteractableException - Selenium web driver cannot click a button while element is visible and clickable, throws org.openqa.selenium.ElementNotInteractableException 出现错误:无法访问 org.openqa.selenium.virtualauthenticator.HasVirtualAuthenticator - Getting error: cannot access org.openqa.selenium.virtualauthenticator.HasVirtualAuthenticator 代码运行正常,但突然“无法解析导入的org.openqa.selenium.WebDriver” - Code was working fine but all of a sudden “The import org.openqa.selenium.WebDriver cannot be resolved” 错误:java:找不到org.openqa.selenium.HasInputDevices的org.openqa.selenium.HasInputDevices类文件 - Error: java: cannot access org.openqa.selenium.HasInputDevices class file for org.openqa.selenium.HasInputDevices not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM