Reuse Rational Functional Tester scripts on updated applications and avoid errors

Create a user helper superclass to generate resilient scripts

A major concern you have with using an automated testing tool is ongoing maintenance and reuse. As developers continually improve and upgrade applications under test, you need a way to test with saved scripts the upgrades without dedicating hours changing the script. This capability is an increasingly significant factor in automating test projects. This article shows you how to use IBM® Rational® Functional Tester and a user helper superclass to change the object-property weight in one place when your application to be tested has changed. Although you make the change in a single place, you can apply the change to the object-property weight specifications throughout the test script, saving you time and frustration.


Grace Chen (, Test Consultant, TestPro Pty Ltd

Grace Chen is a Test Consultant with TestPro, Ltd. She has worked at TestPro since 2008. She is currently working on health insurance projects. Her areas of expertise include Rational Functional Tester, Rational Quality Manager, and test automation framework.

08 April 2010

Also available in Chinese Russian Vietnamese Spanish

Scripts need to keep up with applications under development

While regression testing, test teams usually generate a set of scripts, even while developers upgrade and change the application. Furthermore, developers might change some object properties or object hierarchies. When testers play back the saved scripts against the upgraded application, playback might return an error that indicates that an object cannot be found.

Scripts find changes that are not errors

You might encounter this scenario: When developers upgrade or change an application, developers also change the title of the window to correspond to the application version. In your saved script map, you captured objects in different object maps for different application screens. Each object map uses the same window object as the parent for each of the objects in the object map hierarchy. The window title is the critical property that is used to identify the object. When you play back the saved scripts against the new version of the application with changed window titles, you receive frequent errors: ObjectNotFound. IBM® Rational® Functional Tester treats the changed titles as errors, because the titles do not match the titles in the script.

Rational Functional Tester object-recognition algorithms are not only based on the object itself. The algorithms also check properties of objects that are higher in the object hierarchy, checking up the chain of parents to the top object.

Resetting hundreds of property weight values wastes time

To stop Rational Functional Tester from treating these property changes as errors, you need to reduce the critical property weight to 0. The changed window title is not, after all, an error. By making such a change Rational Functional Tester does not use this property to identify the object. A global setting for reducing the property weight of the window title does not seem available in Rational Functional Tester. Therefore, you need to manually change the title property weight in each object map that contains that object. Imagine that you have hundreds of object maps that you need to change. Think of the time you might waste on each iteration.

Configure scripts to find errors, not appropriate code changes

You need a programmatic way to set in one place the object-property weight of common objects that tests include. Instead of manually changing the property weight in each object map or recapturing the object, you can change the object-property weight during run time. You add a method to your helper superclass, and then call this method from each script that needs to change the object-property weight. After you add this method, testers can run old scripts against upgraded applications, making few changes to the scripts. Moreover, changes to window titles, for example, do not cause errors.

The helper superclass offers real help

To create a helper superclass that changes the property weight of an object:

  1. In Rational Functional Tester, right-click the project name, and select Add Test Folder.
Figure 1. Create a superclass folder
Right-click Project, and select Add Test Folder
  1. Create a helper superclass file: Click File > New > Helper Superclass.
Figure 2. Create a helper superclass folder
In the File menu, select New and Helper Superclass
  1. In Folder, enter the path to the folder.
  2. Select a project name in the Project list.
  3. Enter a class name in Script name.
Figure 3. Specify a helper superclass name, project, and folder
Select a project folder, and type superclass name
  1. Click Finish. Rational Functional Tester creates a script in the Java™ Editor. You can use the script to manually enter Java code.
  2. Enter the method to be available to the script. Use the following code listing to build your method, making required changes according to your project.
Listing 1. Helper superclass code
package superclasses;
import java.util.Enumeration;
import com.rational.test.ft.script.RationalTestScript;

public abstract class ScriptSuperClass extends RationalTestScript
        public void changeweight(){
         // Get relative object map path for a script.
        String map=this.getScriptName().toString().replace(".", "//");
        String mapName = "resources//"+map+".rftxmap";
        // Path to the project
        String projectDir = "C:\\youtprojectLocation";
        // Opening the object map file
          File f = new File(projectDir, mapName);
          ObjectMap om = ObjectMap.load(f);
                  Enumeration e = om.elements();
                  while (e.hasMoreElements()){
        // Locate the object by its role plays in the UI.
                      IMappedTestObject obj = (IMappedTestObject) e.nextElement();
              String role = obj.getRole().toString();
        		Object titleValue = obj.getProperty(".title");	
                //to reduce the weight of title.
                obj.setProperty(".title", titleValue, 0); 
        // Save the object map, f);

After you create your own helper superclass, use it in your script.

Put the helper superclass to work

  1. In Rational Functional Tester, right-click the script, which is going to use the superclass method you just created.
  2. Select Properties.
Figure 4. Script properties
Right click script, and select Properties
  1. Highlight Functional Test Script in the right pane, and click Browse next to the Helper Superclass field. A specification window opens.
  2. Type the first character of user helper superclass name in Select default helper superclass for the script. Rational Functional Tester prompts you with the matching item.
  3. Select the matching item, and click OK.
Figure 5. Select the superclass for the script
Browse and select the user helper superclass
  1. Call the helper superclass method in your script.
Figure 6. Call superclass method.
Window showing script code

Test changes that matter

Your test team's time is valuable. In regression tests, you need to concentrate on significant changes to the application, not on window titles that change or other minor modifications. With the property weight for the window title set to 0, changes in that aspect of the application under test do not generate errors, freeing your time to concentrate on testing important changes in the application.



Get products and technologies



developerWorks: Sign in

Required fields are indicated with an asterisk (*).

Need an IBM ID?
Forgot your IBM ID?

Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.


All information submitted is secure.

Dig deeper into Rational software on developerWorks

ArticleTitle=Reuse Rational Functional Tester scripts on updated applications and avoid errors