1
我試圖運行Selenium測試爲Maven構建一部分,所以我跟着這個文件中的配置:FirefoxDriver給出NullPointerException異常
http://www.gitshah.com/2010/10/how-to-run-selenium-tests-as-part-of.html
但試圖運行我的測試類時:
public class LoginTest {
private WebDriver driver;
private String baseUrl;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "http://localhost:8080/";
}
@Test
public void testLoginClass() throws Exception {
driver.get(baseUrl + "/MyApp/login");
driver.findElement(By.id("j_username")).clear();
driver.findElement(By.id("j_username")).sendKeys("1");
driver.findElement(By.id("j_password")).clear();
driver.findElement(By.id("j_password")).sendKeys("123456");
driver.findElement(By.id("loginBtn")).click();
}
@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
}
我在這行獲得NullPointerException異常:
driver.get(baseUrl + "/MyApp/login");
請告訴我爲什麼我得到這個錯誤。