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.
This concept is a good way to enhance the knowledge.thanks for sharing. please keep it up Salesforce Online Training Hyderabad
ReplyDeleteGreat blog
ReplyDeletebest training institute for hadoop in Marathahalli
best big data hadoop training in Marathahalli
hadoop training in Marathahalli
hadoop training institutes in Marathahalli
hadoop course in Marathahalli