- 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
Using getTestData to Extract Data from a Text Field
The first example of using getTestData() is one that might not initially seem interesting. You can use getTestData() to retrieve data from text fields. To do so, pass getTestData() an argument of “text;” it returns the text as ITestDataText, which is the simplest subinterface in the ITestData family to work with. It’s simple because you need to know only one method to get the data into a usable string: getText(). As an example, look at these two text fields:
- The Search field at www.google.com <http://www.google.com> (HTML domain)
- The Name field on Classics’ Place an Order window (Java domain)
If you fire up and point the Inspector (see the “Viewing an Object’s Properties” section in this chapter) at each of these objects, you can see that in the case of the HTML text field, you need to get the value property. In the case of the Java Swing field, you need to get the text property. If you use getTestData(), in both cases, you pass an argument of text. This is useful if you want to create a generic method that retrieves text (expressed as a single string) from any type of test object. Listing 3.8 shows both a Java and VB.NET example of using getTestData().
Listing 3.8. Getting data from a text field
Java ITestDataText iData = (ITestDataText)textField().getTestData( "text" ); String value = iData.getText();
VB.NET Dim iData as ItestDataText = textField().getTestData( "text" ) dim value as String = iData.getText()
Notice that in Java, you must explicitly cast to ITestDataText.