New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Comments

Projects
None yet
3 participants
@savvyaxnjxn

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

This comment has been minimized.

Show comment
Hide comment
@anshooarora

anshooarora Jan 12, 2017

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.

Owner

anshooarora commented Jan 12, 2017

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.

@anshooarora anshooarora added the bug label Jan 12, 2017

@savvyaxnjxn

This comment has been minimized.

Show comment
Hide comment
@savvyaxnjxn

savvyaxnjxn Jan 12, 2017

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 commented Jan 12, 2017

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

This comment has been minimized.

Show comment
Hide comment
@savvyaxnjxn

savvyaxnjxn Feb 3, 2017

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());
	}
}

savvyaxnjxn commented Feb 3, 2017

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

This comment has been minimized.

Show comment
Hide comment
@SwathiReddygovind

SwathiReddygovind 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

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 join this conversation on GitHub. Already have an account? Sign in to comment