- Test Script Synchronization
- Placing a Generic Delay in Your Script
- Waiting for Test Objects to Come into Existence
- Timing How Long Something Takes to Execute in a Script
- Working with Test Objects
- Working with the Clipboard Object
- Viewing an Objects Properties
- Retrieving All Properties of a Test Object
- Retrieving the Value of a Single Property
- Programmatically Retrieving Data from an Object in My Application
- Determining a Test Objects Valid Test Data Type Arguments to getTestData()
- Using getTestData to Extract Data from a Text Field
- Using getTestData to Extract Data from a List
- Using getTestData() to Read Data in a Table
- Using getTestData() to Extract Data from a Tree
- Obtaining Data from a Test Object That the Rational Functional Tester Verification Point Wizard Does Not Capture
- Creating a Custom Verification Point
- Changing the Value of a Test Objects Property
- Evolving Custom Scripting into Reusable Methods
- Summary
Retrieving the Value of a Single Property
To retrieve the value of a single property, use the getProperty() method in the TestObject class. You can use getProperty() with both value and nonvalue properties. In this section, the discussion is limited to value properties. The signature of getProperty() for Java is:
Object getProperty( String propertyName )
The signature of getProperty() for VB.NET is:
Function GetProperty( propertyName as String) as Object
The argument is the name of the property whose value you want to retrieve. Because getProperty can be used with any value or nonvalue property, the return type is generic Object. You typically want to cast to a specific type (for example, String).
For value properties, you can even use Rational Functional Tester to generate the code for you.
- Place your cursor at the line in your script where you want the code to generate.
- Insert recording.
- Launch the Verification Point and Action Wizard.
- Click the desired test object.
- In the Select an Action window, click Get a Specific Property Value.
- The wizard will then display all the test object’s value property names and values. Click the property you want, and then click Next.
- In the Variable Name window, enter a variable name to hold the returned value (RFT generates a variable name for you but you will typically always want to change the variable name), and click Finish.
If you selected the label property, Rational Functional Tester generates the following code.
In VB.NET:
Dim buttonLabel As String = PlaceOrder().GetProperty( "label" )
In Java:
String buttonLabel = (String)placeOrder().getProperty( "label" );
In Java, you need to explicitly cast to the correct type. For example, if you retrieve a non-String property value, such as the Background property, you see:
java.awt.Color buttonBackground = (java.awt.Color)placeOrder().getProperty( "background" );
If you pass a property name that does not exist in the object, Rational Functional Tester throws a PropertyNotFoundException.
As you become more comfortable with Rational Functional Tester, you can rely less on the wizard to generate code for you.