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

When you see a recognition failure or warning, look at the log message. At the end of lesson 7, you left the log open. If it is not open, open it by double-clicking the log in the Projects view. One warning remains in the log. The event heading is Object Recognition is weak (above the warning threshold).

Procedure

  1. 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.

  2. Look at the Line Number field in the log. Note the number and close the log to return to Test UI.
  3. Click anywhere in the script window, and then click Navigate > Go to Line.
  4. 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 Test UI window. For example: "43:9" refers to position 9 on line 43.
    The line in your script should be:
    RememberPassword().clickToState(SELECTED); 
    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.
  5. 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

  1. Double-click the rememberPassword object to open it in the object map.
  2. 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.

  3. 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.)
  4. 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 Test UI 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

To add the new object to the map, open ClassicsB and then open the Member Logon window.

Procedure

  1. Click Applications > Run in the object map menu.
  2. Select ClassicsJavaB. (Be sure to pick B).
  3. Click OK.
  4. In ClassicsCD, select any CD and then click Place Order.

    The Member Logon window opens.

  5. 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.

  6. Clear the After selecting an object advance to next page check box if it is selected.
  7. 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.

  8. On the Select an Object page, click Next.
  9. 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.

  10. 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

  1. 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.

  2. 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, Test UI puts the new properties at the top if they are the preferred properties. However, some old administrative properties might be preferred. For example, Test UI 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.

  3. Click Next.

    All scripts that are affected by this change in the object map are listed. Only one script, Classics, is affected.

  4. Click Finish.
  5. In the object map, click the File > Save 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

Now we'll play back the script again on ClassicsB to confirm that it passes.

Procedure

  1. Close both dialogs of ClassicsCD.
  2. In Test UI, click Run Functional Test Script on the toolbar.
  3. 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 Test UI 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.
  4. Close the log.