This chapter will introduce the concept of an automatic object map (also called GUI object map in QA literature) and how Squish implements this concept.
The object map is a tool with the goal to ease the maintenance of test scripts when the application under test changes its object hierarchy or object names.
In a test script, objects are accessed by looking up the object via its fully qualified name or its multi-property name. This is called the real name.
If the name of the object, one of its parent object (for qualified names) or one of the identifying properties (multi-property names) changes, this real name is not valid anymore.
To solve this problems, objects are not looked up directly by its real name anymore. Instead in the test scripts, symbolic names are used. Then, when the object is looked up by its name, the real name for the given symbolic name is looked up in the object map. This way, if the name of an object changes because of any of the given reasons, it is enough to correct one entry in the object map and all test scripts will keep working.
The concept provided above is offered by Squish as well to make the QA engineers' lives easier when the AUT changes in the described manners.
The object map for an application is created automatically when
recording test cases in Squish. The map is saved in the file
objects.map in the test suite's root directory
and applies to all tests of the test suite. Alternatively it is
possible to specify the location of the object map using the
OBJECTMAP key in the
suite.conf of the test suite. The value of this
can be an absolute or relative path. Specifying a different location
of an object map can be useful if e.g. multiple test suites should
share the same object map file.
When recording a test, for each object accessed in the generated script code, an entry is stored in the object map. Initially the symbolic name and the real name of the widget are identical. The only way to distinguish a symbolic object name is its prefix. Concretely, this means a symbolic object name is prefixed by a colon.
Therefore, in the generated test script only symbolic object names will be used by using this prefix. So when Squish executes a test script and an object should be looked up by its name, Squish will retrieve the real name from the object name if this name is prefixed with a colon and will do the runtime object lookup with the real name. If the given object name does not start with a colon, the object is looked up directly with this name.
This means it is possible to mix symbolic and real object names in test scripts without conflicts.
The best way to edit an object map is to click on it in the Squish IDE in the test suite view and edit it in the object map editor which will open up automatically.
If you manually write script code and want to use symbolic names for objects which have not been added to the object map yet, you can insert those entries by editing the object map table.
If the object name for an object changed and you want to correct its real name, you can do this by looking for this object in the object map editor and by editing the real name of the object. A good way to look up the new object name is to use the Spy as discussed Spy (Section 16.8.3).
If you edit the real name of an object, all depending names will be updated automatically. Dependent objects are child objects of the object whose name you are editing.
It is also possible to edit the symbolic name of an object. If you do this, you will also have to edit the scripts using these names, since the symbolic name is the one which is used for the lookup.