To develop support for running tests on the QuickID application, the default implementation of the FindObjectId and Run methods in the TEASampleTestableImp class was replaced with a more meaningful implementation.
In the QuickID, because the application is simple, constant integers were used as object IDs. In production Testing Agents, object IDs are usually dynamic and known only during run time (for example, hWnds).
The object IDs for the QuickID application controls were defined in the Common.h file, as follows:
TEASampleApplication(0) – for the application object
TEASampleNameEdit(1) – for the text box for entering the user's name
TEASampleCitySelector(2)– for the drop-down menu for selecting the city
In the QuickID Testing Agent, the implementation of FindObjectId is in the TEASampleTestableImp class in TEASampleTestableImp.cpp file. The method is implemented as follows:
FindObjectId calls GetElementByDescription with the description UFT One provided.
GetElementByDescription returns the global object that represents the object in the application that matches the description.
UFT One provides the description in XML format according to the Description Schema. The description recursively describes the selected object and its ancestors. GetElementByDescription parses the description to find the lowest object in the hierarchy and returns the global object that corresponds to the type specified for that lowest object.
FindObjectId calls the global object's GetObjectID function, which returns the object ID (integer) for the object in the application that it represents. (This object ID is initialized in the global object when it is created.)
When you design your own Testing Agent, the implementation will probably be more complex, but the principles will be the same.