Convert QTP result to html format(Using VBScript)

QTP generate it's results in XML format. These results are only accessible when the test case has finished execution. Any manipulation that you want to do with the results you can do that only outside of QTP (in case you are looking at the results of QTP script that just ran). This can be achieved by running you script from a external VBS which use QTP AOM for running the script. And once done you can access the script in the external VBS.

Coverting results to HTML:
XSL is a Stylesheet language which can be used to transform a XML in way we want it to be. The output could be a HTML file, a text file, a XML file etc...To do this transformation at run-time we need to load the XML and then the XSL into that and save the output. QTP comes with three different XSL files which are present in the below location

C:/Program Files/Mercury Interactive/QuickTest Professional/dat
PDetails.xsl - Detalied HTML Conversion
PShort.xsl - Short HTML conversion
PSelection.xsl - Selective HTML Conversion

The last one (PSelection.xsl) requires input arguments for the XSL and the first 2 can be simply loaded into the XML.

Code:



sResultsXML = "C:/Results.xml"
sDetailedXSL = "C:/Program Files/Mercury Interactive/QuickTest Professional/dat/PDetails.xsl"
sShortXSL = "C:/Program Files/Mercury Interactive/QuickTest Professional/dat/PDetails.xsl"


ApplyXSL sResultsXML, sDetailedXSL, "C:/Results_Detailed.html"
ApplyXSL sResultsXML, sShortXSL, "C:/Results_Short.html"

Public Function ApplyXSL(ByVal inputXML, ByVal inputXSL, ByVal outputFile)
sXMLLib = "MSXML.DOMDocument"
Set xmlDoc = CreateObject(sXMLLib)
Set xslDoc = CreateObject(sXMLLib)

xmlDoc.async = False
xslDoc.async = False

xslDoc.load inputXSL
xmlDoc.load inputXML

outputText = xmlDoc.transformNode(xslDoc.documentElement)

Set FSO = CreateObject("Scripting.FileSystemObject")

Set outFile = FSO.CreateTextFile(outputFile,True)
outFile.Write outputText
outFile.Close


Set outFile = Nothing
Set FSO = Nothing
Set xmlDoc = Nothing
Set xslDoc = Nothing
Set xmlResults = Nothing
End Function



I have attached the outputs to the post. Just note one thing that in case you want the results to be displayed correctly then the PResults.css file should be present in the same folder as HTML.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值