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?
Asked
Active
Viewed 454 times
1 Answers
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