jszy 2014-11-20
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