这是我的代码:
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 概念后得到的错误消息:
Below is the error message which am getting after declaring webdriver concept:
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程序.
Note: I can able to execute simple java program.
我的 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 在编译时没有解决.
...implies that WebDriver and ChromeDriver wasn't resolved at compiletime.
根据您分享的快照,您的主要问题是您的项目空间中存在多个类似的二进制文件,如下所示:
As per the snapshot you have shared your main issue is the presence of multiple similar binaries within your project space as follows :
因此,您很可能已经从一个 JAR 资源(即 selenium-server-standalone-3.11.0 或 selenium-java-3.11.0 JAR),但 compiletime 类正试图从其他 JAR 中解析.因此您会看到 java.lang.Error: Unresolved compiler questions
As a result it is pretty much possible that you have resolved the WebDriver and ChromeDriver from one JAR resource (i.e. either selenium-server-standalone-3.11.0 or selenium-java-3.11.0 JARs) but compiletime the Classes are trying to get resolved from the other JAR. Hence you see java.lang.Error: Unresolved compilation problems
@Test.@Test.这篇关于java.lang.Error:未解决的编译问题:WebDriver/ChromeDriver 在执行 selenium 测试时无法解析为类型错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何从 Selenium 的 gmail 收件箱中单击特定的电子邮How to click on a Particular email from gmail inbox in Selenium?(如何从 Selenium 的 gmail 收件箱中单击特定的电子邮件?)
如何正确设置 Java/Selenium 配置以运行自动化测试How to properly set up Java/Selenium configuration to run automated tests?(如何正确设置 Java/Selenium 配置以运行自动化测试?)
Selenium - 完整的ajax加载自动滚动到页面底部Selenium - complete ajax loading autoscroll to bottom of page(Selenium - 完整的ajax加载自动滚动到页面底部)
在 Selenium 中为每个元素使用多个定位器的优缺点Pros/cons for using multiple locators per element in Selenium?(在 Selenium 中为每个元素使用多个定位器的优缺点?)
Selenium 在并行运行测试时处理 ProtocolHandshake 错误Selenium handles ProtocolHandshake error while running tests parallel(Selenium 在并行运行测试时处理 ProtocolHandshake 错误)
Selenium:如何通过 executeScript() 发送可变字符串Selenium : How to send variable character strings through executeScript()(Selenium:如何通过 executeScript() 发送可变字符串)