Using XML::XSLT to make your test results pretty

This question came up at QAForums recently:

Q: Is it possible to export QTP results to HTML format?

A: Mercury has provided nearly everything you'd ever need to make this happen, and it's highly customizable if you take the time to learn XSLT.

XSLT is a simple technology, used to transform XML documents into other kinds of documents. QTP comes with three XSL files, which transform the Results.xml file into perfectly readable HTML code.

These stylesheets live in the <QTP root>/dat/ folder (on mine, it's C:/Program Files/Mercury Interactive/QuickTest Professional/dat):
PShort.xsl
PDetails.xsl
PSelection.xsl

When the test run report is generated, it's stored in a directory something like this:
<test folder>/Res1/Report/Results.xml

To see it, you have to add the following line below the XML declaration in Results.xml, so it looks like this:

XML:
  1. <?xml version="1.0"?>
  2. <!-- This assumes you've made the PShort.xsl file available via a web server!! -->
  3. <?xml-stylesheet href="http://localhost/qtp/PShort.xsl" type="text/xsl"?>

 

Then view the Results.xml file in IE (which has an XSL engine built into it).

What we do is, we use an external XSLT transformation tool called 'xsltproc' (which comes from the LibXML2 suite at XMLSoft) to generate an HTML file, which we then upload to a server that archives all our test result information. That way nobody needs Mercury's Results Viewer app (that blasted thing takes you through too many clicks to get what you want, and it doesn't remember your filter preferences from one session to the next... GARR!!!!)

This is much better for everyone on my team.

So, it's not difficult, and you have everything you need already. Now if only there were a way to have QTP insert that stylesheet declaration by default into every test...

 

You do not need to link the xml and the xslt inside the xml file.

You can create a new html that points to a xml file and also a xslt file.

e.g.

// Load XML
var xml = new ActiveXObject(”Microsoft.XMLDOM”)
xml.async = false
xml.load(”Results.xml”)// Load XSL
var xsl = new ActiveXObject(”Microsoft.XMLDOM”)
xsl.async = false
xsl.load(”PShort.xsl”)// Transform
document.write(xml.transformNode(xsl))

You should be able to get QTP to create a html like this to point to the correct results.xml.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值