2

I have converted an image to base64 encoder now I want to embed this into HTML file using VB Script. How can I do that?

halfer
  • 19,824
  • 17
  • 99
  • 186
user90
  • 141
  • 1
  • 4
  • 11
  • 2
    check out http://stackoverflow.com/questions/16545307/can-a-bmp-file-be-stored-in-an-hta-html-vbscript – Alex Jan 28 '15 at 11:11

1 Answers1

0

You can use UFT's RunScript functionality to do this.

Say you have this file called addImage.js (I don't know where you want to insert the img I'll assume you can identify the object somehow, this example assumes an id).

window.addImageToId = function(id, base64) {        
    var img = document.createElement('img');
    img.src = "data:image/png;base64," + base64;
    var parent = document.getElementById(id);
    parent.appendChild(img)
}

Then you can do this in the test.

'# introduce the function into the document's scope
Browser("B").Page("P").RunScriptFromFile "C:\addImage.js" 
Browser("B").Page("P").RunScript "addImageToId('" & theId & "', '" & theBase64 & "')"
Motti
  • 110,860
  • 49
  • 189
  • 262