|
Hi,
I was executing the code in 6th Selenium Training Session. I am facing problem w.r.t. taking screenshots of failed test cases. Although the tests fail, which can be seen in the TestNG Report, the screenshots are missing under test-output folder. The code for the same of @AfterMethod of SelTestCase.java is below.. Pls help
@AfterMethod
public void closeBrowser(ITestResult result) throws IOException {
if (!result.isSuccess()){
File imageFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
String failureImageFileName = result.getMethod().getMethodName()+ new SimpleDateFormat("MM-dd-yyyy_HH-ss").format(new GregorianCalendar().getTime()) + ".png";
File failureImageFile = new File(failureImageFileName);
FileUtils.moveFile(imageFile, failureImageFile);
}
driver.close();
driver.quit();
}
|