Display screenshot on Extent report | Selenium Forum
M
Posted on 12/01/2016
Hi:

I have implemented Module 20 datadriven Maven framework. I added Extent reports to the project and the reports are working fine.

My requirement is - In the reports I want to display the screenshots captured when error occurs.

What I have done so far is
In TestBase class
public void takeScreenShot(String fileName) throws IOException{
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File(prop.getProperty("screenShotsPath")+"\\"+fileName+"_"+CustomListener.iteration_number+".jpg"));
}

I am calling this in my test cases like this:
takeScreenShot(this.getClass().getSimpleName()+"_"+CustomListener.iteration_number);

In the ExtentReport class I have:
//test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("C:\\Workspace\\project\\screenshots\\"+this.getClass().getSimpleName()+"_" +CustomListener.iteration_number.jpg"));

I am not getting any screenshots in the Extent report.

Please help

Thanks

M
Replied on 12/01/2016

i have made this project and its adding screen shot.

Responsive image

M
Replied on 13/01/2016

Hi Ashish:

Can you please share with me the Project? I want to see how you have configured the ExtentManager.java file and calling it in the testcase.java file.

Thanks,


M
Replied on 13/01/2016

hi i have already uploaded the project. check the above comment.