首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FirefoxDriver给出NullPointerException

FirefoxDriver给出NullPointerException
EN

Stack Overflow用户
提问于 2012-01-15 11:00:23
回答 1查看 542关注 0票数 1

我试图将selenium测试作为maven构建的一部分,因此我遵循了本文档中的配置:

http://www.gitshah.com/2010/10/how-to-run-selenium-tests-as-part-of.html

但是当尝试运行我的测试类时:

代码语言:javascript
复制
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:

代码语言:javascript
复制
driver.get(baseUrl + "/MyApp/login");

请告诉我为什么会有这个错误。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-01-15 11:44:12

使测试类扩展TestCase后解决的错误

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8869186

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档