// Handle any kind of Unexpected alerts so it shouldn't affect other Tests execution
@AfterMethod()
public void afterMethodOperations(ITestResult result) {
if (Tools.isAlertPresent()) {
Tools.alertConfirm();
}
if (result.getStatus() == ITestResult.FAILURE) {
// When Verification Fails from Item Show, Control will shift to
// After Method
// So To Close any new opened Tabs.
final ArrayList<String> tabs = new ArrayList<String>(driver.getWindowHandles());
for (int i = 1; i < tabs.size(); i++) {
driver.close();
}
driver.switchTo().window(tabs.get(0));
}
}
@AfterMethod()
public void afterMethodOperations(ITestResult result) {
if (Tools.isAlertPresent()) {
Tools.alertConfirm();
}
if (result.getStatus() == ITestResult.FAILURE) {
// When Verification Fails from Item Show, Control will shift to
// After Method
// So To Close any new opened Tabs.
final ArrayList<String> tabs = new ArrayList<String>(driver.getWindowHandles());
for (int i = 1; i < tabs.size(); i++) {
driver.close();
}
driver.switchTo().window(tabs.get(0));
}
}
No comments:
Post a Comment