|
代码我是按照书上抄写的,一下是我抄写的代码:
###########################报告生成#############################
Private Function HReport (ExpectedValue, ActulValue,testStatus,nodename)
Set oEventDesc = CreateObject("Scripting.Dictionary")
' 添加状态
oEventDesc("Status") = micFail
' 添加是否过滤
oEventDesc("EnableFilter") = False
' 添加节点名称
oEventDesc("NodeName") = nodename
' 添加HTML结果
oEventDesc("StepHtmlInfo") = "<TABLE border = '1'>" & _
"TR><TD> Actual Value </TD> <TD> " +ExpectedValue+ "</TD></TR>"&_
"TR><TD> Expected 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 ValidateProperty (Object,PropertyName,ExpectedValue)
' 判断预期值是否与实际值相等
If Object.GetROProperty(PropertyName) = ExpectedValue Then
' 成功
HReport ExpectedValue,Object.GetROProperty(PropertyName),true,_
"check " +Object.GetTOProperty("testObjName") + "<" + PropertyName+">属性"
ValidateProperty = True
Exit Function
else
' 失败
HReport ExpectedValue,Object.GetROProperty(PropertyName),false,_
"check " +Object.GetTOProperty("testObjName") + "<" + PropertyName+">属性"
ValidateProperty = False
Exit Function
End If
End Function
Set oWebEdit = Browser("百度一下,你就知道").Page("百度一下,你就知道").WebEdit("搜索框")
ValidateProperty oWebEdit,"name", "wd"
ValidateProperty oWebEdit, "name", "wd1" |
|