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();
}
}
错误图片:
我在我的类路径中添加了
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)
可能是您的 selenium jar 文件配置不正确或不存在, 试试这个 - https://www.youtube.com/watch?v=8XZT1oOg7as 或尝试这个 - https://www.youtube.com/watch?v=OHtRHXPJn7U
我认为这可能会有所帮助,我遇到了同样的问题并且它有效。
检查您是否添加了正确的selenium jar 文件