@AfterMethod
public void getResult(ITestResult result) throws Exception{
if(result.getStatus() == ITestResult.FAILURE)
{
extentlogger.log(Status.FAIL, MarkupHelper.createLabel(result.getThrowable() +
" - Test Case Failed", ExtentColor.RED));
try {
// get path of captured screenshot using custom failedTCTakeScreenshot method
String screenshotPath = takeSnapShot(result);
extentlogger.fail("Test Case Failed Snapshot is below " +
extentlogger.addScreenCaptureFromPath(screenshotPath));
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
The above code is the code I'm using after method in TestNG. Am I doing anything wrong?enter image description here
You don't have any method named as takeSnapShot or its not declared as public:
Create a method in base class with below content or just directly add below code in the aftermethod hook by replacing takeSnapShot step: