Wednesday 4 September 2013

WebDriver does not close firefox browser when test case fails

WebDriver does not close firefox browser when test case fails

i am using webdriver 2.35 and following is tearDown setUp
@AfterClass
public static void seleniumTearDown() throws Exception {
// teardown code goes here
LoginToApp loginInstance = new LoginToApp();
loginInstance.logoutFromApp();
try {
writeToFile(environmentData);
} catch (Exception e) {
e.printStackTrace();
}
SeleniumTestBase.tearDown();
logger.info("**********************WebDriver
stopped***********************");
}
// tear down method in SeleniumTestBase class
public static void checkForVerificationErrors() {
String verificationErrorString =
verificationErrors.toString();
clearVerificationErrors();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
/** Clears out the list of verification errors */
public static void clearVerificationErrors() {
verificationErrors = new StringBuffer();
}
/** checks for verification errors and stops the browser */
public static void tearDown() throws Exception {
try {
checkForVerificationErrors();
} finally {
//delete cookies
driver.manage().deleteAllCookies();
driver.close();
driver.quit();
}
}
now whenever any test case fails firefox browser instance is not getting
closed. any possible reason ?

No comments:

Post a Comment