似乎可以使此代码执行。编译器没有实例化驱动程序。我能做些什么来纠正这一点。无法实例化类型FirefoxDriver
package mypackage;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
org.openqa.selenium.support.ui.ExpectedConditions;
import
org.openqa.selenium.support.ui.WebDriverWait;
public class selenium {
public static void main(String[] args) {
WebDriver driver = (WebDriver) new FirefoxDriver();
WebDriverWait MyWaitlVar= new
WebDriverWait(driver, 10);
String baseUrl =
"http://newtours.demoaut.com";
String expectedTitle = "Welcome: Mercury Tours";
String actualTitle = "";
// launch Firefox and direct it to the Base URL
driver.get(baseUrl);
// get the actual value of the title
actualTitle = driver.getTitle();
/*
* compare the actual title of the page
witht the expected one and print
* the result as "Passed" or "Failed"
*/
if (actualTitle.contentEquals
(expectedTitle)){
System.out.println("Test Passed!");
} else {
System.out.println("Test Failed");
}
//close Firefox
driver.close();
// exit the program explicitly
System.exit(0);
}
}
什么是编译器错误? –
异常在线程“主要” java.lang.Error的:未解决问题汇编: \t不能在mypackage.myclass.main实例化类型FirefoxDriver \t(myclass.java:16) – Ken
尝试使用在[这个]的例子( http://www.seleniumhq.org/docs/03_webdriver.jsp)网站。 –