Skip to content

Base64 Screenshot not attached to extent report when base64 String is long #120

Description

@LearningPur

Hi @anshooarora , I have observed when image converted to base64 and when base64 string is long, it (test execution) takes forever and screenshot doesn't attach to extent report.

Extent report fails to attach the screenshot when base64 String size is big that is something out of control to handle when it convert an image to base64. PLEASE DO PROVIDE SOME SOLUTION

Execution takes forever and fail to attach screenshot in extent report
scenario.write("<img src=data:image/png;base64," + base64String + ">");

Since there is a limitation of character in comment i am attaching base64String in attached zip file. There are 2 text file.

  1. Fail_base64_String_Size_is_Long
  2. Pass_base64_String

base64String.zip

=============================================

Here is the code i have in framework to capture the screenshot and attach to extent report as base64

   TakesScreenshot screenshot = (TakesScreenshot) driver;
    String base64Image = screenshot.getScreenshotAs(OutputType.BASE64);
    scenario.write("<img src=data:image/png;base64," + base64Image + ">");

When i try with this code it seems screenshot is not getting attached to extent report even though base64 string is showing in cucumber.json and it does display in cucumber.html report

TakesScreenshot screenshot = (TakesScreenshot) WebDriverRunner.getWebDriver();
String base64Image = screenshot.getScreenshotAs(OutputType.BASE64);
byte[] htmlImage = ("<img class="col-lg-12" src="data:image/png;base64," + base64Image + "">").getBytes();
scenario().embed(htmlImage, "text/html");

It seems to log the result pass, fail along with screenshot using .embed is not working at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions