Create object repositories

This exercise describes how to create object repositories, which are collections of test objects used to test your app's user interface.

Define UFT Record and Run settings

Configure UFT to learn objects in the MyFlight application as WPF test objects.

Do the following:

  1. Start with the MyFlight solution and test opened in UFT. For details, see Plan your test and create a solution and Create and run GUI tests.

  2. Set UFT's Record and Run Settings to define how UFT learns objects in the app.

    1. Select Record > Record and Run Settings.

    2. Select Record and run only on: Applications opened by UFT and Applications specified below

    3. Click the Add button and browse to the FlightsGUI.exe file at:  <UFT installation folder>\samples\Flights Application\FlightsGUI.exe

      Leave the other options in the Application Details dialog box with their default values.

  3. Click OK to return to the Record and Run Settings dialog box.

  4. Click OK again to return to the main UFT window.

    Then, continue with Spy on objects in the MyFlight application.

Back to top

Spy on objects in the MyFlight application

Spy on the available properties and operations for some objects in the MyFlight application.

Do the following:

  1. Open the MyFlight sample app.

    If it's already open, close it and re-open it to enable UFT to recognize it properly. For more details, see Explore the sample MyFlight application.

  2. In the UFT toolbar, click the Object Spy button .

  3. Drag the Object Spy dialog box to the side, and ensure that the Keep Object Spy on top while spying is enabled.

  4. In the Object Spy, click the pointing hand to start spying. The UFT window is hidden so that you can spy on the MyFlight app.

  5. Hover over the various objects in the MyFlight app and watch the properties and values change in the Object Spy dialog box.

  6. Using the Object Spy's pointing hand, click in the MyFlight Username edit box.

    Notice the changes that occur in the Object Spy dialog box. The Object hierarchy shows a WpfEdit test object named agentName.

  7. Click Close to close the Object Spy.

Back to top

Add specific objects to the object repository

Add specific objects required for your test to the object repository, one by one.

Do the following:

  1. In UFT, select Resources > Object Repository Manager. The Object Repository Manager enables you to manage the object repositories associated with your test, and contain your test objects.

  2. In the Object Repository Manager window, select Object > Add Objects. Both UFT and the Object Repository Manager are hidden.

  3. Click in the MyFlights app Username edit box, and then select the agentName object, and click OK.

    The agentName object is added to the Object Repository along with its parent object, the Micro Focus MyFlight Sample window object.

  4. Repeat the previous two steps to add test objects for the Password edit box and the OK button.

  5. Save the object repository.

    • In the Saved Shared Object Repository dialog, browse to folder where your solution and test is saved, and create a new folder named TutorialObjectRepositories.

      By default, the solution and test folder is C:\%HOMEPATH%\My Documents\Unified Functional Testing.

    • In the File name field, enter the name as Login.

    Note: This step only saves the object repository. It is not yet associated with your test.

  6. Associate the Login object repository with the Login action in your test.

    This enables you to use objects in this repository with any step in the Login action. Do the following:

    1. In UFT's Solution Explorer, browse to and right-click the Login node.
    2. Select Associate Repository with Action, and then browse to the Login.tsr file you created in the previous step. Click Yes in the message box that opens.

    The object repository is now associated with the Login action, and is displayed in the Solution Explorer as a child element of the action.

  7. Save your test. Then, continue to add object repositories for other areas of the MyFlight app.

    For details, see Navigate and learn.

Back to top

Navigate and learn

Use UFT's Navigate and Learn feature to create shared object repositories for each of the remaining pages in the MyFlight app. Navigate and Learn enables you to learn all objects in a page or section of an application at once.

Do the following:

  1. In the MyFlight app, log in to display the Book Flight page. Log in using the following credentials:

    • Username: john
    • Password: hp
  2. Create a new shared object repository. In UFT's Object Repository Manager window, click New .

  3. Continuing in the Object Repository Manager, select Object > Navigate and Learn.

    Both UFT and the Object Repository Manager windows are hidden, and the Navigate and Learn toolbar appears.

  4. Click the Define Object Filter button , and then select All object types.

  5. Have UFT learn all objects in the Book Flight page of the MyFlight app. Do the following:

    1. In the MyFlight app, click the Book Flight's title bar to bring it into focus.
    2. In the Navigate and Learn toolbar, click Learn.

    Note: The MyFlight app flickers, and UFT adds test objects to your new object repository.

    Do not interact with the MyFlight app as UFT completes this process.

  6. Close the Navigate and Learn toolbar to return to UFT and the Object Repository Manager windows.

  7. Save your object repository in the TutorialObjectRepositories directory you created earlier, and name it FlightFinder.

  8. Associate the new FlightFinder.tsr object repository with the FlightFinder action in your test flow.

    For more details, see how you did this above for the Login action.

Create additional object repositories

Repeat these steps to create additional object repositories for the remaining MyFlight app pages. Save your test as you go, and name each object repository according to the associated action name.

Note: Before learning a page, ensure you've selected items or entered text to ensure that all buttons are enabled. This ensures that UFT learns these button objects properly.

Action and repository summary

When you're done, your test will have object repositories for the following pages:

MyFlight page name Object repository name Associated action
Login Login Login
Book Flight FlightFinder FlightFinder
Select Flight SelectFlight SelectFlight
Flight Details FlightConfirmation FlightConfirmation

Back to top

More about objects and object repositories

UFT uses test objects to recognize objects in your apps while running your test.

Each of these test objects is based on UFT's test object model, which is a large set of object types, or classes. Each test object class has:

  • A list of available description properties that UFT can learn the object
  • A list of relevant operations that UFT can perform on that object.

Each test object class is part of a larger test object hierarchy. For example, the agentName test object is a child object of the Micro Focus My Flight Sample window object.

Run-time objects are the actual objects in your app. When you add an object to an object repository, UFT learns the properties of the run-time object and translates them into UFT test objects.

Object repository recommendations

We recommend:

Back to top

Next steps: