Lesson 8: Update the object map
In this lesson, you will fix the object recognition warning by using the object map. You will also use a regular expression for more flexible object recognition.
To start at the beginning of the tutorial, see the Rational® Functional Tester Tutorial.
When you see a recognition failure or warning, look at the log message. At the end of Exercise 7, you kept the log open. If it is not open, open it by double-clicking it in the Solution Explorer.
One warning remains in the log. The event heading is Object Recognition is weak (above the warning threshold).
-
Look at the ObjectLookedFor and objectFound fields in the warning section near the bottom of the log.
In ClassicsA, the name of the password field is Remember Password. In ClassicsB it is Remember The Password. When you played back the script on ClassicsB, the object recognition did not match exactly because of this difference.
- Look at the Line Number field in the log. Note the number and close the log to return to Rational® Functional Tester.
- Click anywhere in the script window, and then click Edit > Go to.
- Type the line number from the log failure message, and click OK.The cursor moves to the left margin of that line number.Note: You can also find the line number by looking at the indicator in the bottom of the Rational® Functional Tester window. The line number and cursor position within the line is shown there. For example, "Ln 66 Col 9" refers to the position on line 66 that is 9 characters to the right of the left margin.The line in your script should be:
RememberPassword().ClickToState(SELECTED)
This line represents your click on the password check box. This line in the script shows which object is failing. Now you can look for that object in the object map.
- To find the object, return to the list of Test Objects in the Script Explorer
(left pane).
You should see
RememberPassword
listed under the Test Objects folder.
View the object recognition properties in the object map
- Double-click the rememberPassword object to open it in the object map.
- Click Test Object > Accept All on the object map menu. If
the command is grayed out, don't do anything.
Notice that all the objects change to black text. The text is blue (to indicate new objects) until you accept the objects in a map. You should accept the objects the first time you look at a newly created object map.
- If the password check box object is not selected in the map, select it.
(It is the object called
Java: checkBox: checkRemeber: javax.swing.JCheckBox
.) - Look at the recognition properties listed in the Recognition tab
at the bottom of the object map.
You can see that this is the object from ClassicsA, because it says
Remember Password
in the accessibleContext.accessibleName property. This is the old object. However, when you played back the script on ClassicsB, the text for that object changed, so Rational® Functional Tester recognizes it as a new object. You want to use the new object properties in this case, so you must add it to the map.
Add the new object to the map
To add the new object to the map, open ClassicsB and the Member Logon dialog box.
- Click Applications > Run in the object map menu.
- Use the arrow to select ClassicsJavaB. (Be sure to pick B.)
- Click OK.
- In ClassicsCD, select any CD and click Place Order.
The Member Logon dialog box opens.
- Move the object map lower on your screen, if necessary, to see all of
it. In the object map menu, click Test Object > Insert Object(s).
This is the same as the Object Finder tool in the Select an Object page of the Verification Point Wizard.
- Clear the advance to next page option if it is selected.
- Use the Object Finder tool to select the Remember the Password check
box in the Member Logon dialog box.
After you select the check box, you'll see that the accessibleContext.accessibleName property is now "Remember The Password." Stretch the borders of the object map, if necessary, to see the properties.
- On the Select an Object page, click Next.
- Don't change anything on the Select Object Options page,
and click Finish.
The new check box object is now shown in the object map.
- Click another object and notice that the new item is listed in blue and
the word "New" appears at the beginning of the line.
Now both the old and the new objects are listed in the map. You want to unify the two objects and take the properties from each that you want for the new object.
Unify the objects
- To unify the objects, click the old object (the original check box labeled
"CheckBox: checkRemember"), and drag it onto the new object in the list. Position
the tip of the cursor arrow over the new object before you release the mouse
button.
The Unify Test Objects wizard appears.
- Widen the Unify wizard if necessary to see more of the information in
the lower sections.
In the lower left section, the original object's properties appear. It should be labeled "Source: RememberPassword." That is what the text was on the check box in ClassicsA. In the lower right section, it should be labeled "Target: RememberThePassword." That is what the text is on the check box in ClassicsB. Because you dragged the old object to the new object, the new object's recognition properties are filled in at the top. In general, Rational® Functional Tester puts the new properties at the top if they are the preferred properties. However, some old administrative properties may be preferred. For example, Rational® Functional Tester retains regular expressions in the old property set. To use a property from the old object, double-click that property in the grid of the old object and it will be copied up into the unified object. In this case, we want to use all the properties of the new object, which are already filled in.
- Click Next.
All scripts that are affected by this change in the object map are listed. Only one script, Classics, is affected.
- Click Finish.
- In the object map, click File: Save to save the changes you made, and close the object map.
Play back the script again
Now we'll play back the script again on ClassicsB to confirm that it passes.
- First close both dialog boxes of ClassicsCD.
- In Rational® Functional Tester, click Run Functional Test Script.
- Select the Classics log and click Finish.
The script now passes with no warnings! Notice that the playback no longer pauses on the check box object because the recognition properties now match.
This object unification feature is an easy way to update scripts when recognition properties of an object intentionally change. One of the major advantages of this feature is that if your object map is being used by many scripts, you could update them all when you make the change in the wizard. Instead of manually editing multiple scripts, you can make the change once in the map and it propagates automatically to all scripts that use it. This feature can save you time.
Note: There is also an easier way to update the recognition properties of a test object should they change. Instead of using the Unify Wizard as described in this step, from the Object Map you can simply select the test object whose recognition properties you want to update. Right-click on the test object as it is displayed in the Object Map tree and select Update Recognition Properties from the pop-up menu. You will need to have the test application running when this action is performed so that Rational® Functional Tester can get the updated recognition properties. You would only use this update method if you do not want to use any properties of the old object. - Close the log.
Advance to Lesson 9: Change the Recognition Preferences.