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.
About this task
Procedure
-
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 .
-
Type the line number from the log failure message, and then 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. For example: "43:9" refers to position 9 on line 43.The line in your script should be:
This line represents your click action 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.RememberPassword().clickToState(SELECTED);
-
To find the object, return to the list of Test Objects in the Script Explorer (right
pane).
You should see
rememberPassword
listed under the Test Objects folder.
View the object recognition properties in the object map
Procedure
- Double-click the rememberPassword object to open it in the object map.
-
Click
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: checkRemember: 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 text 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
About this task
Procedure
- Click in the object map menu.
- Select ClassicsJavaB. (Be sure to pick B).
- Click OK.
-
In ClassicsCD, select any CD and then click Place Order.
The Member Logon window opens.
-
Move the object map lower on your screen, if necessary, to see all of it. In the
object map menu, click
.
This is the same as the Object Finder tool in the Select an Object page of the Verification Point Wizard.
- Clear the After selecting an object advance to next page check box if it is selected.
-
Use the Object Finder tool to select the Remember the Password
check box in the Member Logon window.
After you select the check box, you'll see that the text 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 then 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" is displayed 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
Procedure
-
To unify the objects, click the old object (the original check box labeled
CheckBox: checkRemember) and then 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. Then, release the mouse button.
The Unify Test Objects wizard opens.
-
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 are shown. 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 of the wizard. In general, Rational® Functional Tester puts the new properties at the top if they are the preferred properties. However, some old administrative properties might 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 the menu on the object map toolbar to save the changes you made and then close the object map.
Play back the script again
About this task
Procedure
- Close both dialog boxes of ClassicsCD.
- In Rational® Functional Tester, click Run Functional Test Script on the toolbar.
-
Select the Classics log and then click
Finish.
The script now passes with no warnings! Notice that the playback no longer pauses on the password 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 a change once in the map and the change propagates automatically to all scripts that use it. This feature can save you time.
Another way to update recognition properties: 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 exercise, from the Object Map you can select the test object whose recognition properties you want to update. Right-click 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.