【发布时间】:2019-12-24 00:04:08
【问题描述】:
问题是:
1) 在我的简单程序中,如何在运行前识别每一行中的错误?
2) 我把我的程序放在这里,在运行时我遇到了很多错误。我该如何解决?
计划:
package newpackage;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Myclass {
public static void main(String[] args) {
System.out.println("Chrome is selected");
System.setProperty("webdriver.chrome.driver","C:\\ProgramFiles\\Chrome65.0.3325.146\\googlechromeportable.exe");
WebDriver driver= new ChromeDriver();
driver.get("https://www.facebook.com/");
driver.manage().window().maximize();
//XPath for Email Field
driver.findElement(By.xpath("//*[@id='login']")).sendKeys("xxx@gmail.com");
//XPath for Password Field
//driver.findElement(By.xpath("//*[@id='pass']")).sendKeys("xxxxxxx");
driver.findElement(By.xpath("//*[@id=\"u_0_a\"]")).click();
}
}
错误:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
WebDriver cannot be resolved to a type
ChromeDriver cannot be resolved to a type
By cannot be resolved`enter code here`
By cannot be resolved
at newpackage.Myclass.main(Myclass.java:16)
【问题讨论】:
-
您是否遇到任何其他错误,还是仅此一个?
-
只有这个