In Order to prevent exception handling in each method in selenium page objects, i thought to have a general exception handling, a try catch in the test block, other handlers only if more specific handling required,
Now the issue is that this process needs to be written in each test... is there a way to make the test methods have this common test handling written once for all tests?
@Test
public void test(WebDriver driver) {
try {
// common code in the try block
// using testNG may be moved to @BeforeMethod And @AfterMethod
Logger.log("Test Started....");
Logger.log("Test Ended....");
Assert.assertAll();
}
catch() {
// in Case Automation Fails, common operations required
ScreenShoot.getScreenShoot();
}
finally
{
// finally for all tests
driver.close();
}
}
Aucun commentaire:
Enregistrer un commentaire