I am automating a web page, and in a class I have several tests and when i run them through testng all of them the @Aftertest isn´t being invoked so the only test that works is the first one, because when the first test finished, it doens't call the aftertest to close the driver instance and start a new one. There are my methods:
@BeforeSuite
public void printInfo() {
Utilidades.addInformationTest();
}
@BeforeTest
public void loggerUser() throws Exception {
initializeSelenium("VerificacionUI_FraudMonitor_Issuer");
Utilidades.printInfo("Cargando datos de variables.");
setCMSModulo(modulo);
setUsuario(usuario);
setContraseña(contraseña);
startAccess();
parentWindowHandle = driver.getWindowHandle();
}
@AfterTest
public void shutDownSelenium() {
driver.quit();
}
and then come all of my six @Test
If any could tell me what im doing wrong, because im clueless. I no each test works individually becuase i've tried it.
Thanks.
Analogous an @After annotated method gets executed after every @Test method. This can be used to repeatedly set up a Test setting and clean up after every test. So the tests are independent and preparation code is not copied inside the @Test method.
@AfterTest: A method with this annotation will be executed when all @Test annotated methods complete the execution of those classes inside the <test> tag in the TestNG. xml file. @BeforeSuite: It will run only once, before all tests in the suite are executed.
I think you might want to try @AfterMethod, instead of @AfterTest.
@AfterTest only runs once, after all of the @Test methods have run.
See the TestNG annotations documentation:
http://testng.org/doc/documentation-main.html#annotations
@AfterMethod: The annotated method will be run after each test method.
@AfterTest: The annotated method will be run after all the test methods belonging to the classes inside the tag have run.
Good Luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With