Querying values of object properties

Components in the application-under-test, such as dialog boxes, command buttons, and labels, have associated pieces of information called properties. Properties have a name and a value. This topic provides some examples of why you may want to modify your script to access an object property.

  • You may want to compare previous versions of a value to the current value and to do so would require a calculation (such as factoring in a depreciation rate).
  • Sometimes querying a property may return a reference to other objects. In cases like this, you might need to test the value of a property of the returned object. This kind of scenario cannot be handled through the user interface. See Unregistering References to Test Objects for more information.
  • You also might want to branch in your test script based on the current value of a property.

You can retrieve the value of a property programmatically by calling the GetProperty method, which has the following syntax:


     Object .GetProperty(ByVal PropertyName As String)

The following example uses the GetProperty method to test whether a value of a property is being captured and reproduced correctly. The call to GetProperty retrieves the value of the text property associated with the ThankYouXLabel object.

#Region " Script Header "
' Functional Test Script
' author Administrator
Imports Microsoft.VisualBasic
Imports Rational.Test.Ft
Imports Rational.Test.Ft.Object.Interfaces
Imports Rational.Test.Ft.Object.Interfaces.SAP
Imports Rational.Test.Ft.Object.Interfaces.Siebel
Imports Rational.Test.Ft.Script
Imports Rational.Test.Ft.Value
Imports Rational.Test.Ft.Vp
#End Region

Public Class QueryingObject
    Inherits QueryingObjectHelper

    'Script Name   : QueryingObject
    'Generated     : Jul 20, 2006 2:20:49 PM
    'Description   : Functional Test Script
    'Original Host : Windows XP x86 5.1 build 2600 Service Pack 2 

    'since  2006/07/20
    'author Administrator

    Public Function TestMain(ByVal args() As Object) As Object
        StartApp("ClassicsJavaA")

        ' Frame: ClassicsCD
        PlaceOrder().Click()

        ' Frame: Member Logon
        OK().Click()

        ' Frame: Place an Order
        CardNumberIncludeTheSpacesText().Click(AtPoint(53, 4))
        PlaceAnOrder().InputChars("1234123412341234")
        ExpirationDateText().Click(AtPoint(10, 5))
        PlaceAnOrder().InputChars("12/12")
        PlaceOrder2().Click()

        'Waiting for Object 
        YourOrderHasBeenReceivedYourOr().WaitForExistence()

        'Querying the Object
        Dim confirmationText As String = YourOrderHasBeenReceivedYourOr().GetProperty("text")
        LogTestResult(confirmationText, confirmationText.startsWith("Your order has"))
        YourOrderHasBeenReceivedYourOr().Click()
        ' 
        OK2().Click()

        ' Frame: ClassicsCD
        ClassicsJava(ANY, MAY_EXIT).Close()
        Return Nothing
    End Function
End Class


HCL OneTest UI also supports a SetProperty method, but do not use it unless you are sure of the result. This method calls internal methods that may violate the integrity of the application-under-test.