Stage 6: Implementing Additional ITestable Interface Methods

This section describes additional methods in the ITestable interface that you must implement in your Testing Agent. This section explains the use of each method when UFT One calls it, and how it was implemented in the QuickID Testing Agent.

GetParent

The GetParent method receives an object ID and returns the object ID of the object's parent. For more information, see Understanding the External Parent Concept and Implementing GetParent.

UFT One calls the GetParent method to build the test object hierarchy. For example, when trying to learn an object from a location in the application to which the UFT One user points. UFT One displays the hierarchy of relevant test objects in the Object Selection dialog box, enabling the UFT One user to select the correct object. To build this hierarchy, GetParent is called for each test object.

In the QuickID Testing Agent, the GetParent method is implemented in the TEASampleTestableImp class in file TEASampleTestableImp.cpp. It was implemented as follows:

  1. The Testing Agent's GetParent method calls GetElementByRuntimeID, with the object ID it received.

  2. GetElementByRuntimeID determines the application object to which the object ID refers and returns the global object that represents that application object.

  3. The Testing Agent's GetParent method calls the global object's GetParent method with the object ID it received. The GetParent method for the global objects is implemented in the base global class, CTEASampleObject. See the TEASampleObject.h file.

  4. The global object's GetParent method returns the global object that was defined as its parent when it was constructed. In QuickID there are only two possible return values:

    • NULL, if the input object is the application object and has no parent

    • g_pTEASampleApplication, if the input object was one of the application controls.
      g_pTEASampleApplication is the global object that represents the application itself.

  5. If the global object's GetParent method returns NULL, the Testing Agent's GetParent method returns VT_EMPTY, indicating that the specified object is the top level object and has no parent.

  6. Otherwise, the Testing Agent's GetParent method calls the parent global object's GetObjectID to return the object ID for the object in the application that it represents. In this case, the method returns the object ID of the application control.

    Back to top

GetChildren

The GetChildren method receives an object ID and returns a list of its children's object IDs. For more information, see Implementing GetChildren.

UFT One calls GetChildren, for example, when running a test step with the operation ChildObjects.

The GetChildren method implementation in the QuickID Testing Agent is similar to the GetParent implementation, as you can see in the TEASampleTestableImp class.

Back to top

GetDisplayName

The GetDisplayName method receives an object ID and returns the display name defined for the specified object. For more information, see Implement GetDisplayName: Return an Object's Name.

UFT One displays the name returned by GetDisplayName in various places, such as the object repository, the Keyword View and the Editor. UFT One also calls GetDisplayName repeatedly when it builds the hierarchy displayed in the Object Selection dialog box.

The GetDisplayName method implementation in the QuickID Testing Agent is similar to the GetParent implementation, as you can see in the TEASampleTestableImp class.

Back to top

GetElementType

The GetElementType method receives an object ID and returns the test object class that represents it. For more information, see Implementing GetElementType and GetProperties.

UFT One displays the name returned by GetElementType in various places, such as the object repository, the Keyword View and the Editor. UFT One also calls GetElementType when it builds the hierarchy displayed in the Object Selection dialog box, to retrieve the test object class for each object in the hierarchy.

The GetElementType method implementation in the QuickID Testing Agent is similar to the GetParent implementation, as you can see in the TEASampleTestableImp class.

Back to top

GetProperties

The GetProperties method receives an object ID and a SAFEARRAY of property names and returns the values of the listed properties. For more information, see Implementing GetElementType and GetProperties.

UFT One calls GetProperties, for example, to display identification properties in the Object Spy, or when running a test step with the GetROProperty (or GetROProperties) operation.

In the QuickID Testing Agent, the GetProperties method is implemented in the TEASampleTestableImp class in file TEASampleTestableImp.cpp. It was implemented as follows:

  1. The GetProperties method calls GetElementByRuntimeID, passing it the object ID GetPropertiesreceived.

  2. GetElementByRuntimeID determines the application object to which the object ID refers and returns the global object that represents that application object.

  3. For each property name in the received list, the Testing Agent's GetProperties calls the global object's GetProperty method with the property name.

  4. The GetProperty method for the global objects is implemented in the base global class, CTEASampleObject in file TEASampleObject.cpp. Because the global object properties are initialized when the object is created, and updated every time the application changes, GetProperty returns the value of the property directly from the global object.

Back to top

BuildDescription

The BuildDescription method receives an object ID and returns a description that uniquely identifies this object in the application. The description must recursively describe the entire test object hierarchy for the specified test object. The object description must be provided in XML format according to the AppDescription Schema.

In addition to the description, BuildDescription can set the externalParent argument to instruct UFT One to integrate the test object hierarchy of the Testing Agent's testing environment in the larger test object hierarchy of the application being tested. The QuickID application is a stand-alone application, therefore the agent does not set the externalParent argument.

UFT One calls the BuildDescription method before added an object to the object repository. For more information, see Implementing BuildDescription: Map an Object ID to a Description.

In the QuickID Testing Agent, the BuildDescription method is implemented in the TEASampleTestableImp class in file TEASampleTestableImp.cpp. It was implemented as follows:

  1. The BuildDescription method calls GetElementByRuntimeID, with the object ID it received.

  2. GetElementByRuntimeID determines the application object to which the object ID refers, and returns the global object that represents that application object.

  3. The Testing Agent's BuildDescription method calls the global object's BuildDescription method with all of the parameters that UFT One passed.

  4. The BuildDescription method for the global objects is implemented in the CTEASampleObject class in file TEASampleObject.cpp. The global object contains all of the information required to build the object description: the identification property names and values, and the parent object ID. The BuildDescription method recursively builds the XML object description according to the AppDescription Schema. Only identification properties that were defined with a for description attribute in the testing environment XML are included in the description.

Back to top

GetLastError

UFT One calls the GetLastError method when the Testing Agent returns an error code. The GetLastError method should return a message that can be displayed to the UFT One user, explaining the error that resulted from the previous action. For more information, see Implementing the GetLastError Method: Reporting Errors.

The QuickID Testing Agent was implemented to save an error message in a private data member (m_bsLastError) whenever one of its methods returns an error code. When UFT One calls GetLastError the Testing Agent simply returns the value of this data member.

The following methods from the ITestable interface were not fully implemented in the QuickID Testing Agent:

Based on what you have learned from the process of creating the QuickID Testing Agent, you can implement these methods in your Testing Agent, to provide full support of these UFT One basic capabilities if required.

Back to top