【发布时间】:2012-02-10 18:07:36
【问题描述】:
我正在尝试在 maven build 中运行 selenium 测试,因此我遵循了本文档中的配置:
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");
请告知我为什么会收到此错误。
【问题讨论】:
标签: spring jakarta-ee maven-2 selenium continuous-integration