2

Ques 1)I have converted an image to base64 encoder now i want to embedd this into html file using vbscript.

Ques2) I want to click on a word which would open this encoded image like how
"a href" works.I want to see the image only when the link is clicked.

I got answer to my first ques.Can anyone help me solving 2nd ques?

Thanx in advance.

user90
  • 131
  • 1
  • 3
  • 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
  • Please don't ask multiple questions together, it's hard to track what answers which part. Also stack overflow questions are cheap.... – Motti Jan 29 '15 at 15:28

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
  • 105,704
  • 46
  • 182
  • 255
  • @user90, if this answered you question, please consider accepting the answer (by clicking the tick mark underneath the score) – Motti Jan 29 '15 at 15:25