extentreports-csharp icon indicating copy to clipboard operation
extentreports-csharp copied to clipboard

Screenshots are not attached after migrating from htmlReporterV3 to V4

Open ParagRaut opened this issue 6 years ago • 7 comments

I have migrated from V3 HTML reporter to V4 HTML reporter. I use BDD style reporting. Before my screenshots worked just fine, whole logic is same. I'm attaching screenshots via AddScreenCaptureFromPath(path to screenshot) method Add in .png format. File size is also reasonable

If I use ExtentV3HtmlReporter(path to report) it works just fine, but when I try ExtentHtmlReporter(path to report) it fails to attach screenshot.

I'm very confused of why my screenshot is not being attached. is that a pro feature now ?

Sample step I used to attach screenshot:

case "Given":
ScenarioName.CreateNode<Given>(stepName)
                            .Fail($"Exception:\n{errorMessageOrException}, \nURL: {webDriverUrlOrNull}")
                            .AddScreenCaptureFromPath(logic to get screenshot string);

Sample screenshot of report: image

ParagRaut avatar Apr 15 '19 15:04 ParagRaut

Update: I can have screenshots attached to report with following code:

case "Given":
ScenarioName.CreateNode<Given>(stepName)
                            .Fail($"Exception:\n{errorMessageOrException}, \nURL: {webDriverUrlOrNull}",MediaEntityBuilder.CreateScreenCaptureFromPath(logic to get path to screenshot file).Build());

It looks little odd though image

Previous option was far better and screenshots looked fine

ParagRaut avatar Apr 15 '19 15:04 ParagRaut

Update: I can have screenshots attached to report with following code:

case "Given":
ScenarioName.CreateNode<Given>(stepName)
                            .Fail($"Exception:\n{errorMessageOrException}, \nURL: {webDriverUrlOrNull}",MediaEntityBuilder.CreateScreenCaptureFromPath(logic to get path to screenshot file).Build());

It looks little odd though image

Previous option was far better and screenshots looked fine

I tried to use the code with MediaEntityBuilder.CreateScreenCaptureFromPath (logic to get path to screenshot file) .Build ()), but it doesn't attach anything to me, could you share the complete code or explain to me better how you did to attach the images to the report?

I use this:

var screen = ((ITakesScreenshot)_webdriverContext.driver).GetScreenshot(); _scenario.CreateNode<Given>(_scenarioContext.StepContext.StepInfo.Text).Pass("", MediaEntityBuilder.CreateScreenCaptureFromPath(".\\", screen + ".jpeg").Build());

RodrigoGambino avatar Mar 23 '20 20:03 RodrigoGambino

Hi Good morning! Is this now working? I wanted to add this to my project and confirm it's working before setting everything up.

AutomationSifu avatar Apr 29 '20 14:04 AutomationSifu

Is this issue being fixed?

darrendeng777 avatar Jun 09 '20 15:06 darrendeng777

@darrendeng777 Please use the latest version 4.1.0-beta1 from nuget with ExtentHtmlReporter and let me know if you continue to have issues.

anshooarora avatar Jun 09 '20 20:06 anshooarora

I have the same issue. But I am using dotnet core. What is the compatible version for ExtentReports.Core to make this work ?

KHariHaraChaitanya avatar Aug 05 '20 05:08 KHariHaraChaitanya

@KHariHaraChaitanya Please use this package: https://www.nuget.org/packages/ExtentReports/4.1.0-beta1

anshooarora avatar Aug 06 '20 17:08 anshooarora