Skip to content
This repository has been archived by the owner on Jul 17, 2020. It is now read-only.

v3.0.1 Extent Report - Screenshots only appear for the most recently executed test #726

Closed
savvyaxnjxn opened this issue Dec 30, 2016 · 4 comments
Labels

Comments

@savvyaxnjxn
Copy link

savvyaxnjxn commented Dec 30, 2016

I've really enjoyed getting to know the Extent Report tool over the past few weeks! I've plunged in with the latest v3.0.1 and have used it to run back-to-back test cases for hours on end with Selenium WebDriver and our Jenkins CI Server. As expected, the reports that are produced (both locally and from the CI Server) take and store every screenshot that is coded. However, when a new report is appended (.setAppendExisting(true)) the html report file wipes out the tags that contain the data-featherlight img reference from the previous report and the screenshots only appear for the most recently executed test.

If it helps, the method I'm using to make the entry in my log is as follows (inputs are my WebDriver and the Test I'm appending the screenshot to):

public void captureAndDisplayScreenShot(WebDriver ldriver, ExtentTest eTest){
        String extentReportImage = "../extentReport/screenshots/" + System.currentTimeMillis() + ".png";
        // Take screenshot and store as a file format
        File src=((TakesScreenshot)ldriver).getScreenshotAs(OutputType.FILE);
        try {
            // now copy the  screenshot to desired location using copyFile method
            FileUtils.copyFile(src, new File(extentReportImage));
            eTest.log(Status.INFO,"Screenshot from : " + extentReportImage).addScreenCaptureFromPath(extentReportImage);
        } catch (IOException e)
        {
            System.out.println(e.getMessage());
        }
    }

Please advise if there is anything more I can provide! Thank you again for your work on a great product; the shop loves it!

@anshooarora
Copy link
Owner

I am able to repro this. However, you must note that this will only appear at the test level. If you have added any screenshots to logs, they will appear so until the next release can you add screenshots to the logs? See here for more info.

PS. I am marking this as a defect to fix the parser for tests.

@savvyaxnjxn
Copy link
Author

Excellent insight! I'll try to shift things to logs as per the linked example for the time being and eagerly await the next release. Is there any sort of user-acceptance-testing that I could volunteer for that would help you out pre-release? I don't have gobs of time, but if you could use an extra pair of eyes when that day comes I might be available. Cheers!~

@savvyaxnjxn
Copy link
Author

For anyone looking for my work-around for the time being, I've utilized @anshooarora's suggestion based upon the examples in the 'Insert Screenshots'. This keeps the screenshots in-line (as opposed to grouped at the end of the test as I was originally doing) so IMO they actually look nicer and multiple steps & tests can all be appended without anything getting lost. Also note that as of v3.0.2 MediaBuilder is deprecated and (at least for this example) the updated method 'MediaEntityBuilder' can be utilized.

public void captureAndDisplayScreenShot(WebDriver ldriver, ExtentTest eTest){
	 String extentReportImage = "../extentReport/screenshots/" + System.currentTimeMillis() + ".png";
	// Take screenshot and store as a file format
	File src=((TakesScreenshot)ldriver).getScreenshotAs(OutputType.FILE);
	try {
		// now copy the screenshot to desired location using copyFile method
		FileUtils.copyFile(src, new File(extentReportImage));
		eTest.log(Status.INFO, "Screenshot from : " + extentReportImage, MediaEntityBuilder.createScreenCaptureFromPath(extentReportImage).build());
	} catch (IOException e)
	{
		System.out.println("Error in the captureAndDisplayScreenShot method: " + e.getMessage());
	}
}

@SwathiReddygovind
Copy link

SwathiReddygovind commented Dec 4, 2017

@anshooarora Under categories section it is showing only recently Executed Testcase when I use setAppendExisting(true) Method in between Screenshots and two testcases are logged correctly.Except under Category Section it is showing the count only 1 as i have 2 passed.Could you please tell me the issue
dashboardcatgeroy
screenshot

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants