1

I have written C# code to get base64 encoded string as a screenshot and place it into .html Extent Report.

    private ExtentReports Extent;
    private ExtentTest Test;
------- some other code here ----------

    Test = Extent.CreateTest("name of my test as string");

    public void AddTestFailureScreenshot(string base64ScreenCapture)
    {
        Test.AddScreenCaptureFromBase64String(base64ScreenCapture, "Screenshot on Error:");
    }

    public string ScreenCaptureAsBase64String()
    {
        ITakesScreenshot ts = (ITakesScreenshot)driver;
        Screenshot screenshot = ts.GetScreenshot();
        return screenshot.AsBase64EncodedString;
    }

When the report is generated in .html format, I can't see the embedded screenshot right away, rather I need to click on base64-img link and then image loads normally (image shows that one of our pre-prod environment is down)

enter image description here enter image description here

enter image description here

This happens in Firefox and Google Chrome. I am just trying to figure out if the problem with Extent Reports code that I have provided, or some configuration in the browser itself.

Has anybody faced a similar problem before? I simply want screenshots to appear without any additional clicking.

TiredOfProgramming
  • 845
  • 2
  • 16
  • 41

1 Answers1

3

Your problem is in the HTML, the "href" attribute is used for links. You must use the "src" attribute.

As demonstrated in this Example.

I hope it serves you and those who have this concern.

If you can mark me as "correct answer" I would really appreciate it.

KR Akhil
  • 877
  • 3
  • 15
  • 32