我试图将selenium测试作为maven构建的一部分,因此我遵循了本文档中的配置:
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");请告诉我为什么会有这个错误。
发布于 2012-01-15 11:44:12
使测试类扩展TestCase后解决的错误
https://stackoverflow.com/questions/8869186
复制相似问题