QTP 自定义html测试报告
Private Function HReport(ExpectedValue,ActualValue,testStatus,nodename) Set oEventDesc = CreateObject("Scripting.Dictionary") //创建一个key-value字典 oEventDesc("Status") = micFail //本代码中无实际意义 oEventDesc("EnableFilter") = False //同上 oEventDesc("NodeName") = nodename //报表root名字 oEventDesc("StepHtmlInfo") = "<TABLE BORDER='1'>"&"<TR><TD>ActualValue</TD><TD>"+ActualValue+"</TD></TR>"&_ "<TR><TD>ExpectedValue</TD><TD>"+ExpectedValue+"</TD></TR>"&"<TR><TD>Checkpoint Status</TD><TD style='background:red'><b>Failed</b></TD></TR></TABLE>" If testStatus Then oEventDesc("Status") = micPass oEventDesc("StepHtmlInfo") = Replace(oEventDesc("StepHtmlInfo"),"<TD>Checkpoint Status</TD><TD style='background:red'><b>Failed</b></TD>",_ "<TD>Checkpoint Status</TD><TD style='background:green'><b>Passed</b></TD>") End If newEventContext = Reporter.LogEvent("Replay",oEventDesc,Reporter.GetContext) //LogEvent这个官方并没有公开这个方法 详细介绍Reporter 看http://www.ltesting.net/ceshi/ceshijishu/rjcsgj/mercury/quicktestpro/2011/1215/203769.html Set oEventDesc = Nothing End Function Function ValidateProperty(Object,PropertyName,ExpectedValue) If Object.getROProperty(PropertyName) = ExpectedValue Then HReport ExpectedValue,Object.getROProperty(PropertyName),true,"check "+Object.getROProperty("testObjName")+"<"+PropertyName+">属性" ValidateProperty = true Exit Function Else HReport ExpectedValue,Object.getROProperty(PropertyName),false,"check "+Object.getROProperty("testObjName")+"<"+PropertyName+">属性" ValidateProperty = false Exit Function End If End Function Set oWebEdit = Browser("百度一下,你就知道").Page("百度一下,你就知道").WebEdit("wd") ValidateProperty oWebEdit,"name","wd" ValidateProperty oWebEdit,"name","wd1" //OProperty("testObjName") 隐藏方法,得到Object属性名,这里结果为name,个人理解是wd为属性值,name为属性命。本代码中没有感觉到实际意义。 // 以上代码是摘自http://www.iquicktest.com/lectures-qtp-htmlreporter.html
相关推荐
lupeng 2020-11-14
sjcheck 2020-11-10
sjcheck 2020-11-03
meylovezn 2020-08-28
owhile 2020-08-18
Francismingren 2020-08-17
pythonclass 2020-07-29
sunzhihaofuture 2020-07-19
爱读书的旅行者 2020-07-07
行吟阁 2020-07-05
tianqi 2020-07-05
行吟阁 2020-07-04
冰蝶 2020-07-04
lyg0 2020-07-04
owhile 2020-07-04
opspider 2020-06-28
lengyu0 2020-06-28
tianqi 2020-06-21
dadaooxx 2020-06-16