Selenium WebDriver无法解析为类型
正在尝试设置Selenium,但无法获取Eclipse中调用浏览器的代码。我有以下代码:Selenium WebDriver无法解析为类型,selenium,webdriver,selenium-chromedriver,Selenium,Webdriver,Selenium Chromedriver,正在尝试设置Selenium,但无法获取Eclipse中调用浏览器的代码。我有以下代码: package Basics; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class Browserinvocation { public static void main(String[] args) { // TODO Auto-g
package Basics;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Browserinvocation {
public static void main(String[] args) {
// TODO Auto-generated method stub
WebDriver driver=new ChromeDriver();
}
}
我收到以下错误:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
WebDriver cannot be resolved to a type
ChromeDriver cannot be resolved to a type
at Basics.Browserinvocation.main(Browserinvocation.java:11)
在StackOverflow上有一个类似的问题,解决方案是在“Lib”文件夹外有2个jar没有添加。我也错过了这些,但即使添加了那些罐子,我仍然收到相同的错误
另外,当我将鼠标悬停在“org.openqa.selenium.WebDriver;”上时,会收到以下消息:
The import org.openqa cannot be resolved
我在java项目库中添加了外部jar
client-combined-3.2.0-nodeps.jar
,解决了这个问题,因为它位于根文件夹中,所以之前没有添加它。听起来您仍然有jar问题。查找教程并遵循其安装指南,确保您拥有所有最新的驱动程序等,并且它们与您的浏览器版本相匹配。