我在Selenium Webdriver中编写了长测试套件(超过100个测试),用Java和TestNG编写 . 当我只进行最后一组测试(名称'v1870')时,在20次测试中,我经常在测试后获得成功 . 但是当我开始全部测试时,我在最后一组的小组测试中得到了一些补偿 .

我使用注释来清除驱动程序:

@AfterClass(alwaysRun = true)
public void tearDown() throws Exception {
    if (driver != null) {
        driver.quit ();
    }
    String verificationErrorString = verificationErrors.toString ();
    if (!"".equals (verificationErrorString)) {
        Assert.fail (verificationErrorString);
    }
}

出于某些原因,我失败了 . (断言错误或org.openqa.selenium.NoSuchSessionException:会话ID为null . 调用quit()后使用WebDriver?)

我该怎么做才能清除所有必要的东西?
例如,我认为,我可以在20个课程/考试后清除所有内容,但是如何?