Implementing the Run Method

After implementing the FindObjectId method, the default implementation of the Run method in the TEASampleTestableImp class was replaced with a more meaningful implementation that supports running tests on the QuickID application.

UFT One calls the Run method to carry out test steps. The Run method receives:

  • The object ID of the application object on which the step needs to be performed

  • The name of the test object method to perform

  • A SAFEARRAY list of arguments for the test object method

For example, when running a test on the QuickID application, the Run method can be called with the TEASampleCitySelector test object, the Select test object method, the argument 2 (which is the index entry for NewYork in the cities list).

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

  1. The Testing Agent's Run 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 Run method calls the global object's Run method with all of the parameters that UFT One passed.

  4. The Run method for the global objects is implemented in the base global class, CTEASampleObject in file TEASampleObject.cpp. This method delegates the request to the RunMethod function of the QuickID application dialog object. This is an object of class CTEASampleDlg, implemented in file TEASampleDlg.cpp. The CTEASampleObject object actually carries out the operation in the test step.

  5. RunMethod determines the application object on which the step needs to be performed and the test object method that needs to be run, and performs the test object method on the appropriate application object.

  6. For example, if RunMethod is called with the TEASampleCitySelector object, the Select test object method, and the index entry for one of the cities in the list, RunMethod calls CTEASampleDlg::SelectCity with the provided index entry. SelectCity obtains a pointer to the drop-down menu control and calls its SetCurSel with the index of the city to select. SetCurSel performs the selection of the city.

    In addition, SelectCity also updates the selectedCity property of the g_pTEASampleCitySelector global object, which represents the drop-down menu control. This enables the global object to provide the correct value for the selectedCity property when UFT One requests it.

    If RunMethod is called with the TEASampleApplication object and the DisplayDetails operation, it simulates the operation of clicking the OK button by calling CTEASampleDlg::OnBnClickedButtonok. The application's OnBnClickedButtonok method displays the appropriate information in the text box.