任务是从HTML文件中获取数据,当我们单击提交按钮时,将下载包含输入数据的文件,并且应打开QTP并将下载的文件用作测试数据。在以下代码中 案例1:当我在Chrome中使用时,文件已下载,但QTP未打开 案例2:当我在IE中使用时,QTP是无关的,但文件没有被下载。
请修改代码,以便两者都能正常工作
<html>
<head>
<script language="javascript">
function exportF() {
document.getElementById("input").innerHTML =
document.getElementById("text").value;
document.getElementById("input1").innerHTML =
document.getElementById("text1").value;
document.getElementById("input2").innerHTML =
document.getElementById("text2").value;
var table = document.getElementById("table");
var html = table.outerHTML;
var url = 'data:application/vnd.C:\\Users\patilch\Desktop\test.xlsx,' +
escape(html); // Set your html table into url
var link = document.getElementById("downloadLink");
link.setAttribute("href", url);
link.setAttribute("download", "export.xls"); // Choose the file name
link.click(); // Download your excel file
var qtApp = new ActiveXObject("QuickTest.Application");
qtApp.Launch(); // Start QuickTest
qtApp.Visible = true;
return false;
}
</script>
</head>
<body>
<div class="container">
<header>
<h1>Payment Processing</h1>
</header>
</div>
<content>
<form onsubmit="return exportF()">
<table>
<tr>
<td>File Path</td>
<td>Sap Generated Path</td>
<td>Result</td>
</tr>
<tr>
<td> <input id="text" type="text" /></td>
<td> <input id="text1" type="text" /></td>
<td> <input id="text2" type="text" /></td>
<td><input type="submit" value="RUN"/></td>
</tr>
</table>
</form>
</content>
<table id="table" style="display: none">
<tr>
<td id="input">
<td id="input1">
<td id="input2">
</td>
</tr>
</table>
<a style="display: none" id="downloadLink"></a>
</body>
</div>
</html>
答案 0 :(得分:0)
另一种可能的方法是从HTML执行.vbs文件。您可以查看更多相关信息here
在您的vbs文件中,您可以使用VBS中的以下代码轻松打开QTP
Set qtpApp=CreateObject("QuickTest.Application")
qtpApp.Launch
qtpApp.Visible = True
这是尝试它的一种非正统方法,你必须检查如何与当前脚本集成