Open topic with navigation
Using the Object Spy pointing hand mechanism, the UFT user can view the supported properties and operations of any visible object in an open application. As the user moves the pointing hand over the objects in the application, their details are displayed in the Object Spy. These details may include the test object's hierarchy tree, its properties and values, and its operations.
For UFT to display the test object details in the Object Spy, it calls several of the ITestable interface methods described earlier (GetDisplayName, GetElementType, GetParent, GetProperties, and so on). However, for UFT to be able to determine which application object is located where the user is pointing, the Testing Agent must also implement the ISpyable interface. The ISpyable interface contains only the GetElementFromPoint method. This method receives the coordinates of the location to which the user pointed (on the application), and returns the object ID of the application object located at that point. For more information, see Implementing GetElementFromPoint.
In the QuickID Testing Agent, the support for the Object Spy was implemented as follows:
In the TEASampleTestableImp.h file:
The following line was added to the CTEASampleTestableImp class inheritance list to indicate that it implements the ISpyable interface:
public IDispatchImpl<ISpyable, &__uuidof(ISpyable), &LIBID_AutInterface>
The following line was added to the CTEASampleTestableImp class' COM Map:
All of the methods in the ISpyable interface were declared in the CTEASampleTestableImp class.
The Testing Agent's GetElementFromPoint method was implemented in the TEASampleTestableImp.cpp file as follows:
The global object's GetElementFromPoint (implemented in the CTEASampleObject class, see the TEASampleObject.cpp file) returns the global object of the innermost application object containing the specified point.
To find the appropriate object, GetElementFromPoint recursively checks all of the global objects, until it finds the innermost object that contains the specified point. If an appropriate object was found, it is returned. Otherwise, if the point is contained in the application, the method returns the global object that represents the application itself.
To find out whether a point is contained in a specific object, CTEASampleObject::GetElementFromPoint calls CTEASampleDlg::IsPointInObject, with the point and the object's ID. IsPointInObject calls a private GetRectangle method which receives an object ID and returns the rectangle containing the object. Then IsPointInObject checks whether the specified point is contained in the rectangle and returns the answer.
The Testing Agent's GetElementFromPoint method takes the global object returned from the g_pTEASampleApplication's GetElementFromPoint, queries it for the object ID of the object it represents, and returns this object ID.