【发布时间】:2019-04-23 12:54:32
【问题描述】:
我的 selenium 脚本有问题,可能是 Eclipse 中的问题
package Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class Test {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","C:\\Chromedriver.exe");
WebDriver driver = new ChromeDriver();
String baseUrl = "https://www.facebook.com/";
driver.get(baseUrl);
WebElement email = driver.findElement(By.id("email"));
WebElement password = driver.findElement(By.id("pass"));
WebElement login = driver.findElement(By.xpath("//*[@id='loginbutton']"));
email.sendKeys("abcd@gmail.com");
password.sendKeys("abcd123");
login.click();
System.out.println("Login Done with Click");
}
}
错误:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
WebDriver cannot be resolved to a type
at Test.Test.main(Test.java:15)
这是我的 JAR 库结构:
【问题讨论】:
标签: selenium selenium-webdriver webdriver selenium-chromedriver