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");
请告诉我为什么我得到这个错误。