My Blog List

Wednesday, December 28, 2016

Generate Test Execution Report with Screenshots inbuilt

How to generate HTML report with inbuilt screenshots?

Lot of automation testers would come across this path while trying to integrate their automation solution with some test management tool or trying to send the execution report to management team. The main issue we face here is that we need to attach the screenshots also while sending or uploading into another tool.
What would you think if we can convert the image into bytes and store it inside the HTML itself?
Yes. You are right. We can attach the screenshots and report statements in one single html file and easily we can attach or send it to anybody.

Function convertImageToBytes(strScreenshotFilePath)
  Dim streamInput, bytesStream, oDOM, tmpElement
  
  Set streamInput = CreateObject("ADODB.Stream")
  Set oDOM = CreateObject("Microsoft.XMLDOM")  
  streamInput.Open
  streamInput.Type = 1  ' adTypeBinary
  streamInput.LoadFromFile strScreenshotPath
  bytesStream = streamInput.Read  
  
  Set tmpElement = oDOM.createElement("tmp")
  tmpElement.dataType = "bin.base64"
  tmpElement.nodeTypedValue = bytesStream
  convertImageToBytes = "data:image/png;base64," & Replace(tmpElement.text, vbLf, "")
End Function

You can get this content and assign to some attribute in html; and you can utilize it to build some logic around it to show the screenshot.
You can get lot of examples for this html logic in w3schools.

3 comments:

  1. Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article.thank you for sharing such a great blog with us. expecting for your.
    Digital Marketing Company in India

    ReplyDelete
  2. Inspiring writings and I greatly admired what you have to say , I hope you continue to provide new ideas for us all and greetings success always for you..Keep update more information..

    Home Spa Services in Mumbai

    ReplyDelete
  3. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.

    Digital Marketing Company in India

    ReplyDelete