HTML模式自定义reporter

来源:互联网 发布:大淘客cms网站搭建 编辑:程序博客网 时间:2024/05/21 06:34
Option explicit
private function Hreport(expectedValue, ActualValue, testStatus, nodename)
Dim oEventDesc, newEventContext
Set oEventDesc = CreateObject("scripting.Dictionary")
oEventDesc("Status") = micFail
oEventDesc("EnableFilter") = False
oEventDesc("NodeName") = nodename
oEventDesc("StepHtmlInfo") = "<table border='1'>" &"<tr><td>Expected Value</td><td>"+expectedValue+"</td></tr>" & _
"<tr><td>Actual Value</td><td>"+ActualValue+"</td></tr>"&"<tr><td>Checkpoint Status</td><td style='background-color:red'><b>Failed</b></td></tr></table>"
If testStatus Then
oEventDesc("Status") = micPass
oEventDesc("StepHtmlInfo") = Replace(oEventDesc("StepHtmlInfo"), "<td style='background-color:red'><b>Failed</b></td>", "<td style='background-color:green'><b>Passed</b></td>")
End If
newEventContext = Reporter.LogEvent ("Replay", oEventDesc, Reporter.GetContext)
Set oEventDesc = nothing
end function


Function VaildateProperty(object, PropertyName, ExpectedValue)
   If object.GetROProperty(PropertyName) = ExpectedValue Then
  Hreport ExpectedValue, object.GetROProperty(PropertyName), true, "检查 "+object.GetTOProperty("testObjName")+"<"+propertyName+"> 属性"
  VaildateProperty = true
       Exit function
else
Hreport ExpectedValue, object.GetROProperty(PropertyName), false, "检查 "+object.GetTOProperty("testObjName")+"<"+propertyName+"> 属性"
VaildateProperty = false
Exit function
   End If
End Function