extent-framework / extentreports-csharp

Extent Reporting Library, .NET
http://extentreports.com
Apache License 2.0
50 stars 39 forks source link

Image not being created in screenshot? #190

Closed Fergal-C closed 1 year ago

Fergal-C commented 1 year ago

Windows NET version 7.0.10 Extent Reports 5.0.0

I am using the following code to generate a screenshot for a failed test, but no image is actually being created in the test report:

test.Fail("Screenshot", MediaEntityBuilder.CreateScreenCaptureFromPath("." + @"/extent.png").Build());

Screenshot

The file path, from the broken image, appears correct "Reports/2023/12Sep/extent.png", where the report is stored in "Reports/2023/12Sep/"

Is there a known reason why the screenshot image is not created?

(Apologies if this is not an appropriate place for this question.)

anshooarora commented 1 year ago

Can you check the HTML on the report for the image path using devtools? Try using "extent.png" directly?

Fergal-C commented 1 year ago

Thanks anshooarora,

This is the image html from the report in dev tools: <img data-featherlight="./extent.png" src="./extent.png">

When the code is changed to: test.Fail("Screenshot", MediaEntityBuilder.CreateScreenCaptureFromPath("extent.png").Build());

The img html from the report in DevTools changes to <img data-featherlight="extent.png" src="extent.png">

But the image still does not load. Screenshot2

I also can't find the image locally, when I search for it in File Explorer, it seems like it is not being created.

anshooarora commented 1 year ago

This method will not capture a screenshot, but merely create the relevant link to the report given the path.

Fergal-C commented 1 year ago

Thanks very much again anshooarora, that's exactly what I was misunderstanding. All working now.