这是我的代码:
package seleniumTutorials; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; public class BasicsSelenium { public static void main(String[] args) { boolean status; status=true; boolean newstatus = false; System.out.println("My Old status was "+status); System.out.println("My new status was "+newstatus); System.setProperty("webdriver.chrome.driver", "F:\\Samraj\\MavenAutomation\\Jar Files\\Selenium Java\\chromedriver.exe"); ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.addArguments("--start-maximized"); WebDriver driver = new ChromeDriver(chromeOptions); driver.get("dev.findmyfare.io"); System.out.println(driver.getTitle()); } }
以下是在声明webdriver概念后收到的错误消息:
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 seleniumTutorials.BasicsSelenium.main(BasicsSelenium.java:13)
注意:我可以执行简单的Java程序。
我的Eclipse的屏幕截图
此错误消息…
Exception in thread "main" java.lang.Error: Unresolved compilation problems: WebDriver cannot be resolved to a type ChromeDriver cannot be resolved to a type
…暗示 WebDriver 和 ChromeDriver 在 编译 时未解决。
根据您共享的快照,主要问题是项目空间中存在 多个 类似的二进制文件,如下所示:
结果,很可能您已经从一个JAR资源(即 selenium-server-standalone-3.11.0 或 selenium- java-3.11.0 JAR) 解析* 了 WebDriver 和 ChromeDriver ,但是 编译时 类试图获取从其他JAR解决。因此,您会看到 java.lang.Error:未解决的编译问题 ***
@Test