GetRoProperty In QTP

How To : 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 operations 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 operation:

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

Using the Exist operation:

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


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."


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


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

              VerifyDisabled = False

       End If

End Function 

Retrieving Native Properties

You can use the Object property to access the native properties of any run-time object. For example, you can retrieve the current value of the ActiveX calendar's internal Day property as follows:

Dim MyDay

Set MyDay=Browser("index").Page("Untitled").ActiveX("MSCAL.Calendar.7").Object.Day

The below stuff is very important and very frequently used by any QTP programmer in Object identification using QTP.

Post a Comment


Close Menu