无法使用 selenium 运行 ChromeDriver

问题描述 投票:0回答:2
package testPackage;

import org.openqa.selenium.chrome.ChromeDriver;

public class TestClass {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
    
        System.setProperty("webdriver.chrome.driver", "./Driver/chromedriver.exe");
        // Create a new instance of the ChromeDriver
        ChromeDriver driver = new ChromeDriver();

        
    }

}

错误图片: enter image description here

我在我的类路径中添加了

selenium-java-4.9.0.jar
。 但我仍然收到错误:-

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    ChromeDriver cannot be resolved to a type
    ChromeDriver cannot be resolved to a type

    at TestProject/testPackage.TestClass.main(TestClass.java:12)
eclipse selenium-webdriver selenium-chromedriver
2个回答
0
投票

可能是您的 selenium jar 文件配置不正确或不存在, 试试这个 - https://www.youtube.com/watch?v=8XZT1oOg7as 或尝试这个 - https://www.youtube.com/watch?v=OHtRHXPJn7U

我认为这可能会有所帮助,我遇到了同样的问题并且它有效。


0
投票

检查您是否添加了正确的selenium jar 文件

© www.soinside.com 2019 - 2024. All rights reserved.