【问题标题】:FirefoxDriver gives NullPointerExceptionFirefoxDriver 给出 NullPointerException
【发布时间】:2012-02-10 18:07:36
【问题描述】:

我正在尝试在 ma​​ven 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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多