@AfterMethod public void catchExceptions(ITestResult result) { System.out.println("result" + result); String methodName = result.getName(); System.out.println(methodName); if (!result.isSuccess()) { try { File scrFile = driver.getScreenshotAs(OutputType.FILE); FileUtils.copyFile( scrFile, new File("C:\\MacmillanProjects\\target\\TestArtefacts\\Test_failing-shot.jpg")); } catch (IOException e1) { e1.printStackTrace(); } } }