【发布时间】:2021-12-26 08:51:09
【问题描述】:
这是我的代码:
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程序。
【问题讨论】:
-
您似乎缺少 Selenium 项目的一些罐子。您是否在构建路径中添加了 Selenium 并添加了 jar?
-
同样
driver.get("dev.findmyfare.io")会抛出一个错误。请在网址前使用http或https -
我添加了丢失的 Junit jar,但仍然面临同样的问题。我也将指导网址更改为dev.findmyfare.io。
-
我在使用 Eclipse 时遇到了这个问题,但在使用 NetBeans 时我没有遇到任何问题,我认为这可以帮助您 stackoverflow.com/questions/59361521/…
标签: eclipse selenium selenium-webdriver webdriver selenium-chromedriver