自定义CheckPoint

利用 QTPGetROPropertyReporter ,可以编写自定义检查点函数替代 QTPCheckPoint ,避免移植性和维护性问题。下面的 ValidateProperty 就是这样一个函数:

'Function to validate object property and report status in test results

Function ValidateProperty (Object, PropertyName, ExpectedValue, NodeName)

'First check if the object exists or not

If Not Object.Exist(0) Then

'Report a failure in the test results

Reporter.ReportEvent micFail, NodeName, "The object does not exist"

'Return false

ValidateProperty = False

Exit Function

'Check if actual property value is same a expected value

ElseIf Object.GetROProperty(PropertyName) = ExpectedValue Then

'Reporet success to test results

Reporter.ReportEvent micPass, NodeName, " Property = " & PropertyName _

& ", ExpectedValue = ActualValue = " & ExpectedValue

'Return true

ValidateProperty = True

Exit Function

Else

'Expected and actual values are different. Report failure and

'report both value to report.

Reporter.ReportEvent micFail, NodeName, " Property = " & PropertyName _

& ", ExpectedValue = " & ExpectedValue & ", Actual Value = " & _

Object.GetROProperty(PropertyName)

'Return false

ValidateProperty = False

Exit Function

End If

End Function

'Execute the checkpoint on a object

Set oLink = Browser("Web Tours").Page("Web Tours").Frame("info").Link("sign up now")

ValidateProperty oLink, "html tag", "A", " 验证链接的 html tag 属性 "

ValidateProperty oLink, "innertext", "sign up now", " 验证链接的 innertext 属性 "

ValidateProperty oLink, "text", "sign up now", " 验证链接的 text 属性 "

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值