Home > Articles > Programming

This chapter is from the book

Working with the Clipboard Object

Rational Functional Tester gives you a type of verification point that works with textual data on the Windows Clipboard. You might ask, “Why would I want to use the Windows Clipboard with Rational Functional Tester?” You want to do this for several reasons, but in most cases, it comes down to an easy way to get around object recognition difficulties. Often you need a test script to do something, such as checking a value, and if the normal way to do this (in this example, using a verification point) doesn’t immediately work, using the Clipboard might be the fastest way to make it work.

Getting a test script to work reliably with the application interface you are testing often comes down to robust object recognition. Dealing with object recognition is covered in more detail in Chapter 8, “Handling Unsupported Domain Objects,” and in Chapter 9, “Advanced Rational Functional Tester Object Map Topics.” In some cases, you want to follow that information to fully implement Rational Functional Tester’s recognition and interface with the test objects. The reason that you might not follow that approach, but instead use the Clipboard, usually has to do with how quickly you need to get something to work. Do not think of the Clipboard approach as a work-around or interim solution, though, as it is often the most effective and efficient way to automate a test procedure.

You use the Clipboard for handling object recognition with Rational Functional Tester, which specifically means getting, setting, or otherwise using values from the application under test or associated applications. You might do this for any of the following reasons:

  • Verifying some functionality or output from the application
  • Controlling the timing of your test scripts
  • Manipulating the flow of the test procedures
  • Logging additional information into the test results

When you use this technique, you record steps to copy and/or paste data to the Clipboard, and then use it as a kind of data source. The Clipboard can be used as an intermediate place to hold data from the application under test, and Rational Functional Tester can get data from the Clipboard or send data to it. You can also test anything that gets onto the Clipboard with a verification point.

There are three general approaches to using the Clipboard with automated testing:

  1. Verifying some value from the application
  2. Getting some value from the application to use in the test
  3. Sending some value from the test to the application

For each of these tactics, you usually record some steps to select and copy data from some GUI, and then add some Clipboard actions into the test script. This chapter describes several examples, with specific steps, for each of the three approaches.

You do not have to manually code the methods previously described; you can simply use the Recorder toolbar to generate the Clipboard code. You add these Clipboard actions much like you would other kinds of verification points or script actions. The wizards for adding Clipboard actions into a test are found in the Script Support Functions on the Recorder toolbar.

Figure 3.9 illustrates how to access the Clipboard actions from the Rational Functional Tester Recorder toolbar.

Like all of Rational Functional Tester’s script support functions, you need to click Insert code to add the commands to your test script.

The first consideration you have when using the Clipboard is determining exactly how you can select and copy, or perhaps paste, data to and from the Clipboard. In some cases, you might select text using a mouse click and drag, followed by a Ctrl+C keyboard shortcut. In other cases, you might have a menu option in the application under test to copy information to the Clipboard. You might have to use a combination of interactions with the application under test, the operating system, various keyboard inputs, and right-clicking or other menu selections.

The exact method used to get data to and from the Clipboard is of critical importance to the resilience of the automated test script. Some of the steps that you record, such as clicking and dragging, rely on coordinates within an object. These methods are therefore more susceptible to playback failure. You should always strive to record actions that are most likely to replay in the maximum (and reasonable) test environments and playback conditions.

The following looks at several related examples of creating test scripts that use the Clipboard and starts with one possible scenario of creating automated test scripts leveraging the Clipboard. This is not intended to be the most realistic scenario possible, but it illustrates different ways of using the Clipboard with Rational Functional Tester.

In this scenario, you have to test a system that includes an older reporting component. Rational Functional Tester can recognize only parts of this component’s interface and doesn’t seem to automatically capture a particular value: the current job number. This alphanumeric string has to be checked against expected values and it is used as an input value to another test. Finally, because this is a lower priority test case, you cannot spend too much time developing the test script.

You can figure out how to get Rational Functional Tester to recognize the objects and properties to access the job number value, but that might take time. You realize that the job number field can be easily selected and copied to the Clipboard, so you use the Clipboard to quickly get a working automated test script.

First, you create a Clipboard verification point for the job number value. This differs from other verification points in that you do not directly access the object or properties to get the value. You can record a test script to do this as follows:

  1. Record the initial steps of the test script, getting to the point where the job number (the value we want to verify) is displayed.
  2. Select the job number text and copy it to the Clipboard. A robust method for doing this could be tabbing to the field if the application GUI is not likely to change.
  3. Open the Script Support Functions from the Recorder toolbar, and click Clipboard > Verification Point Tab (see Figure 3.10). You will see the value that was copied in the verification value field.
  4. Enter a descriptive name for the verification point in the VP Name field.
  5. Click Insert Code, and then click Close to exit the Script Support Functions and return to recording mode.

At this point, the script contains the code for a Clipboard verification point, as shown here:


You now get the job number value and store it in a local variable within the test script. You can record a test script to do this as follows:

  1. Record any initial steps of the test script or continue the previous example, getting to the point where the job number (the value we want to capture) is displayed.
  2. Select the job number text and copy it to the Clipboard. If you combine this with the previous verification point example, you can skip directly to the next step.
  3. Open the Script Support Functions, and click Clipboard > Assign Text Tab (see Figure 3.11).
  4. Enter a descriptive name for the script variable in the Variable Name field, and then select Precede variable assignment with type declaration.
  5. Click Insert Code, then click Close to exit the Script Support Functions and return to recording mode.

At this point, the script contains the code for a new string variable to hold whatever was copied to the Clipboard, as shown here:

String JobNum = getSystemClipboard().getText();

This variable can now be used for any number of reasons within the test.

You also have the ability to send data to the Clipboard. You might want to do this if you need to test your application’s paste function. If you set the data in the Clipboard immediately before performing a paste function, you can ensure that you know what should be pasted into your application. Another reason you might do this is for continuity. For example, if one piece of your application provides a record number, you might wish to store it in a variable (for example, JobNum in the preceding line of script). You can then use this variable to paste into the piece of your application that does a record lookup. In any case, setting the Clipboard is easy. You simply use the following line of code in your script:


Returning to the scenario, you now need to enter a new job number, different from the current one, into the application. You want to paste this value from the Clipboard into the application GUI field. You therefore need to set the value contained in the Clipboard. You might calculate or look up the particular value in several ways, but for this example, you simply show a static string. You can record a test script to do this as follows:

  1. Record any initial steps of the test script or continue the previous example, getting to the point where you enter the new value.
  2. Open the Script Support Functions, and then click Clipboard > Set Text Tab. The value field on this tab is empty (shown in Figure 3.12).
  3. Enter the value that you want to send to the Clipboard. You might simply enter a placeholder value when you are recording and then replace it in the script to some calculated or retrieved variable (for example, JobNum).
  4. Click Insert Code, then click Close to exit the Script Support Functions and return to recording mode.

At this point, the script now contains the code to set the value of the Clipboard, as shown here:


As mentioned in step 3, you might want to replace the hard-coded value entered during recording mode (IncrementedJobNumber) with some variable or other value. An incomplete example of this is shown in following code snippet.

// retrieve JobNum from the getText() method
String JobNum = getSystemClipboard().getText();
//replace recorded setText() value to JobNum variable

Instead of using the recorder, you might want to manually add the code for Clipboard interactions. This is easy to do because you would have to add only one line of code for each type of Clipboard action, not counting the lines of script to select, copy, or paste the data. An example of a line to capture something to the Clipboard is:


The preceding line of code performs the following steps:

  1. Press the Home key (that is {ExtHome})—This places the cursor at the beginning of the field.
  2. Perform a Shift+End keystroke combination (that is +{ExtEnd})—This selects everything in the field (from the beginning to the end of it).
  3. Perform the Ctrl+C keystroke combination (that is ^c)—This executes the copy function of the application.

    After this, you can manually add the following line to your script for a Clipboard verification point:


The Rational Functional Tester API has a public interface IClipboard in the com.rational. test.ft.script package that defines the set of methods exposed for a Clipboard. The three methods in this are:

  • getText—Returns a copy of the text from this Clipboard.
  • setText—Copies the supplied text value to this Clipboard.
  • performTest:—Captures, compares, and logs active Clipboard text against the supplied baseline data.

There are several things to consider when using the Clipboard with Rational Functional Tester:

  • The Clipboard is often used to verify, get, and set data without mapping and directly accessing objects and properties. This can make script maintenance more difficult because you do not have an object map of the objects containing the values.
  • The steps used to capture data to the Clipboard or paste data from it might be less resilient and more susceptible to playback problems. This can be a risk if you have to resort to click and drag or other actions using coordinates.
  • There is a risk with the system Clipboard that scripts might not play back the same way in different test environments. Although this should ideally work the same way on Windows and Linux operating systems, it can also fail on the same operating system due to different conditions in the test environment.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020