Open topic with navigation
During a recording session, the Testing Agent can instruct UFT to add steps to the GUI test, based on the operations that the user performs on the application. To do this, the Testing Agent calls the Record API callback method that UFT provides in the IRecorder interface, which is defined in the UFT Extensibility Agent type library. For more information, see Recording Test Object Method Steps .
In the QuickID Testing Agent, support for recording was designed as follows:
In the TEASample.idl file, a new interface, local to the Testing Agent, is defined. This is the ITEASampleTestable interface. This interface defines the communication between the application and the Testing Agent. When the QuickID application runs, it creates a Testing Agent object and stores a reference to the Testing Agent's ITEASampleTestable interface in the local member m_spTea. The ITEASampleTestable interface exposes a Record function.
The QuickID application was designed to call the ITEASampleTestable interface's Record method whenever the UFT user performs an operation for which a step needs to be recorded. The Testing Agent delegates this request to UFT by calling the Record method of the IRecorder interface. The IRecorder interface is exposed by the object reference the agent received in BeginRecording.
If the UFT user starts a recording session and then selects a city from the list of cities displayed in the drop-down menu control, the application's OnCbnSelchangeComboCity handler function is called.
OnCbnSelchangeComboCity calls the Testing Agent's ITEASampleTestable::Record method with the object ID for the drop-down menu control, the operation name (
Select) and the operation arguments. The argument in this case is the index of the selected city. For details on OnCbnSelchangeComboCity, see file TEASampleDlg.cpp.
The additional parameters that need to be provided are a description of the object on which the operation was performed, and a SAFEARRAY containing the object IDs of this object and all of its ancestors up to the root object. The object description must be in XML format according to the AppDescription Schema. To generate the list of object IDs for the drop-down menu control and its parent, the application dialog box, an application-specific method was designed in the CTEASampleObject class—the GetObjectIDHierarchy function.
The Testing Agent instructs UFT what step to record for each user operation. This enables the Testing Agent to support a logical testing model for the application. For example, the operation recorded when the user clicks the OK button on the application is DisplayDetails and not the physical Click operation. This is implemented in the OnBnClickedButtonok method in the TEASampleDlg.cpp file, which calls the Record method from the IRecorder interface, to record the UFT test step.
The implementation of recording an operation performed on the text box was implemented in the OnEnKillfocusEditName handler method in the TEASampleDlg.cpp file.
The ITEASampleTestable interface also exposes the IsRecording method. This method was implemented by the QuickID Testing Agent to return
S_OK if a recording session is currently active and
S_FALSE otherwise. Before calling the Testing Agent's Record method to record a step, the application calls this method to check whether a recording session is active. If there is no active recording session, the Record method is not called. This ensures that the Testing Agent does not attempt to record test steps for every operation that the user performs on the application unless UFT is loaded and a recording session is active.