简体   繁体   English

Eclipse 上的“ChromeDriver/WebDriver can not be resoved to a type”错误

[英]"ChromeDriver/ WebDriver can not be resoved to a type" error on Eclipse

openqa.selenium.WebDriver openqa.selenium.chrome openqa.selenium Project Structure Java Build Path-> Jar files Need help! openqa.selenium.WebDriver openqa.selenium.chrome openqa.selenium项目结构Java Build Path- > Jar files需要帮助! Using Selenium with Java for Chrome Browser on Eclipse.在 Eclipse 上为 Chrome 浏览器使用 Selenium 和 Java。 It's a frequently asked question.这是一个常见问题。 Searched for all the solutions provided, but mine did not get resolved.搜索了所有提供的解决方案,但我的没有得到解决。

Have latest version: Java: openjdk-15_windows-x64_bin Eclipse: for Java Developers Selenium WebDriver Java client: selenium-java-3.141.59 Google Chrome version: 86;有最新版本:Java:openjdk-15_windows-x64_bin Eclipse:面向 Java 开发人员 Selenium WebDriver Java 客户端:selenium-java-3.141.59 Google Chrome 版本:86; chromedriver_win32 of the same version. chromedriver_win32 相同版本。

Trying to instantiate a new chrome driver:尝试实例化新的 chrome 驱动程序:

Have added all the external jars coming from 'Selenium WebDriver Java client: selenium-java-3.141.59' to my project Java Buildpath -> Libraries -> Add External Jars.已将来自“Selenium WebDriver Java 客户端:selenium-java-3.141.59”的所有外部 jar 添加到我的项目 Java Buildpath -> Libraries -> Add External Jars。

My code:我的代码:

    import org.openqa.selenium.By;  
    import org.openqa.selenium.WebDriver;  
    import org.openqa.selenium.chrome.ChromeDriver;
    public class firstProgram {
    public static void main(String[] args) {  
        
        WebDriver driver;           
        System.setProperty("webdriver.chrome.driver", "D:\\ChromeDriver\\chromedriver.exe");  
        driver=new ChromeDriver();  
     
              
        }  
    }

Errors: ChromeDriver can not be resolved to a type WebDriver can not be resolved to a type错误:ChromeDriver 无法解析为类型 WebDriver 无法解析为类型

After adding the import statements, same error for all the three.添加导入语句后,三个都出现相同的错误。 The import.org.---------- can not be resolved. import.org.---------无法解决。

Please let me know what else to be done.请让我知道还有什么要做。 I'm stuck, can not proceed.我卡住了,无法继续。

As @howlger suggested: "Maybe there is another JAR that contains the same package. In this case, you have to move the JARs from the Modulepath to the Classpath."正如@howlger 建议的那样:“也许还有另一个 JAR 包含相同的包。在这种情况下,您必须将 JAR 从模块路径移动到类路径。”

Moving the JARs from Modulepath to Classpath removed the errors and I was able to open chrome webpage.将 JAR 从 Modulepath 移动到 Classpath 消除了错误,我能够打开 Chrome 网页。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM