我已经将图像转换为base64编码器,现在我想使用VB脚本将其嵌入HTML文件中。我该怎么做?
您可以使用 UFT 的 RunScript 功能来执行此操作。
假设您有一个名为 addImage.js
的文件(我不知道您要将img
插入到哪里,我假设您可以以某种方式识别对象,此示例假设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)
}
然后,您可以在测试中执行此操作。
'# introduce the function into the document's scope
Browser("B").Page("P").RunScriptFromFile "C:addImage.js"
Browser("B").Page("P").RunScript "addImageToId('" & theId & "', '" & theBase64 & "')"