Closed iamsraja closed 6 years ago
@anshooarora Hi Anshoo, Could you please help with this issue?
Are you sure this method isn't being called 3 times?
Thanks for the response @anshooarora. If had called thrice, I should have had log message printed 3 times as well.
Can you create a small POC for me to reproduce?
@anshooarora Hi Anshoo, Apologies for the delay. Here is a POC for you to reproduce the issue. ExtentReports.ScreenCapture.zip
Sample screenshot from POC:-
@anshooarora
Cause for issue:-
In Log.cs, For 'Details' attribute,
if (_screenCapture != null)
{
_details = _details + _screenCapture.Source;
_screenCapture = null; (missingcode)
}
return _details;
I'm currently following a workaround to sort this issue,
The code fragment I use,
public void Information(string msg, string screenshotPath)
{
_logger.Warning(msg);
TestCaseReporter.Info(msg,MediaEntityBuilder.CreateScreenCaptureFromPath(screenshotPath).Build());
HtmlReporter.Flush();
TestCaseReporter.GetModel().LogContext().GetLast().ScreenCapture = null;
}
TestCaseReporter is the instance of ExtentTest class
Hi ,
Each time you call this code
Report.HtmlReporter.Flush();
will attach screenshots .
You have called multiple times in your After Scenario,After Step , After Feature .
Use Flush only once.
Hi, was this issue resolved? I am seeing multiple images for a step based on the number of tesc cases left to execute. For example, if am executing 3 tests, then the first test is logging three screenshots for steps where screenshot was taken, second test is logging 2 screenshots for each steps where screenshot was taken and third step is logging 1 screenshot.
Not sure how to fix this. Any help will be greatly appreciated. Thanks.
I was able to find a workaround for my issue above until it gets fixed by the author of Extent Reports API. This is what I am doing at the end of the test in C#.
[TestCleanup]
public void MyTestCleanup()
{
testReport.Flush(); //testReport is my ExtentReports object
int logContextItemCnt = reportTest.GetModel().LogContext().Count; //reportTest is my ExtentTest object
for (int i = 0; i < logContextItemCnt; i++)
{
reportTest.GetModel().LogContext().Get(i).ScreenCapture = null;
}
}
im experiencing the same thing and I only have one instance of flush per test. However, @venug0453 workaround works perfectly to fix the issue in the meantime
@anshooarora We too are seeing this issue.
@ssureshraja This was addressed in 3.1.2. Can you close this issue?
Extent reports 3.0.2 display multiple screenshot images for single log entry as below
The code fragment I use,
public void Information(string msg, string screenshotPath)
{
_logger.Warning(msg);
TestCaseReporter.Info(msg,MediaEntityBuilder.CreateScreenCaptureFromPath(screenshotPath).Build());
}
TestCaseReporter is the instance of ExtentTest class