Home > Articles > Programming

This chapter is from the book

Obtaining Data from a Test Object That the Rational Functional Tester Verification Point Wizard Does Not Capture

This large topic is discussed here and explored in more detail in other sections. Several techniques are used to deal with this challenge, the simplest of which from a coding perspective is to try to get the data into the Clipboard. If this can reliably be done, you can get the data into a script variable (though this technique might not be your first choice).

As discussed in the “Working with the Clipboard Object” section in this chapter, Rational Functional Tester gives you access to the system Clipboard. This provides access to the two methods used for manipulating the Clipboard: setText() and getText(). These enable you to work with test objects that Rational Functional Tester has difficulty extracting data from.

The following reference example is an open document in Microsoft Word. If you point the Rational Functional Tester Verification Point Wizard at a Microsoft Word document, it does not see the contents of the document. You can, however, get the data into a variable in your script by using the keyboard and a little code.

First, you click the document to place keyboard focus on it. Then you use the keyboard to put the data into the Clipboard (versus trying to manipulate the Word menu). The Rational Functional Tester API has two methods to work with the keyboard: inputChars() and inputKeys(). Both take string arguments, but there’s a key difference between them: inputChars() treats every character it has passed literally, and inputKeys() assigns special meaning to certain characters, as shown in Table 3.9.

Table 3.9 Characters with Special Meanings in Scripts


Apply Ctrl to the next character.


Apply Alt to the next character.


Apply Shift to the next character.


Enter key.

Passing inputKeys ^a^c causes Rational Functional Tester to press Ctrl+A (select all) and then Ctrl+C (copy), copying the contents of the entire document to the Clipboard. After the data is copied to the Clipboard, you are home free. To get the data in the Clipboard, you call getSystemClipboard().getText(). This is detailed in Listing 3.13.

Listing 3.13. Using the Clipboard to get data from a test object

((TopLevelSubitemTestObject) microsoftWordDocumentwindow()

String text = getSystemClipboard().getText();
  • + Share This
  • 🔖 Save To Your Account