Performing Programmatic Description Checks

Performing Programmatic Description Checks

You can compare the run-time value of a specified object property with the expected value of that property using either programmatic descriptions or user-defined functions.

Programmatic description checks are useful in cases in which you cannot apply a regular checkpoint, for example, if the object whose properties you want to check is not stored in an object repository. You can then write the results of the check to the Test Results report.

For example, suppose you want to check the run-time value of a Web button. You can use the GetROProperty or Exist methods to retrieve the run-time value of an object or to verify whether the object exists at that point in the run session.

The following examples illustrate how to use programmatic descriptions to check whether the Continue Web button is disabled during a run session.

Using the GetROProperty method:

ActualDisabledVal = Browser(micClass:="Browser").Page(micClass:="Page").WebButton(alt:=Continue").GetROProperty("disabled")

Using the Exist method:

While Not Browser(micClass:="Browser").Page(micClass:="Page").WebButton(alt:=Continue").Exist(30)

Wend

By adding Report.ReportEvent statements, you can instruct QuickTest to send the results of a check to the Test Results.

If ActualDisabledVal = True Then

Reporter.ReportEvent micPass, "CheckContinueButton = PASS", "The Continue button is disabled, as expected."

Else

Reporter.ReportEvent micFail, "CheckContinueButton = FAIL", "The Continue button is enabled, even though it should be disabled."

You can also create and use user-defined functions to check whether your application is functioning as expected. The following example illustrates a function that checks whether an object is disabled and returns True if the object is disabled:

'@Description Checks whether the specified test object is disabled

'@Documentation Check whether the is enabled.

Public Function VerifyDisabled (obj)

       Dim enable_property

       ' Get the disabled property from the test object

       enable_property = obj.GetROProperty("disabled")

       If enable_property = 1 Then ' The value is True (1)—the object is disabled

              Reporter.ReportEvent micPass, "VerifyDisabled Succeeded", "The test object is disabled, as expected."

              VerifyDisabled = True

       Else

              Reporter.ReportEvent micFail, "VerifyDisabled Failed", "The test object is enabled, although it should be disabled."

              VerifyDisabled = False

       End If

End Function 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/16792402/viewspace-567245/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/16792402/viewspace-567245/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值