Create modular object repositories

This step describes how to create modular object repositories for each of the actions in your test.

While each action is created by default with a local object repository, objects stored there are only accessibly by that action. We recommend creating modular object repositories, which enable you to access and reuse the test objects in actions across your test.

Create a Login object repository

By default, when you performed the steps in Record your first action, UFT saved the test objects used for the recorded steps in the local object repository.

This procedure describes how to save those test objects in a separate, modular object repository.

Do the following:

  1. In the Solution Explorer, expand the Solution WebTutorial > AdvantageDEMO > Login action.

  2. Double-click the Local object repository to open it.

  3. Select File > Export and replace local objects. In the Export Object Repository dialog that opens, do the following:

    1. Browse to the C:\Users\<user>\Documents\Unified Functional Testing\WebTutorial directory.

    2. In the File name field, enter Login.

    3. Click Create.

    The test objects used in this action are moved from the Local object repository to a new object repository, named Login.tsr.

  4. Save your test.

View your test object details

Double-click the Login.tsr node to open the new object repository. In the Object Repository Manager, select File > Enable Editing to view the details clearly.

Each of the test objects used in your recorded action are listed in a hierarchy under the Advantage Shopping page test object. Click each test object to view details on the right, including object properties and identifiers.

Create additional object repositories

The rest of the exercises in this tutorial teach you how to create test steps manually.

To do so, you must have test objects already existing in object repositories. We recommend creating a modular object repository for each action in your test.

Continue with:

  1. Create a SelectLaptop object repository
  2. Create a Checkout object repository
  3. Create a Logout object repository

Back to top

Create a SelectLaptop object repository

Create an object repository with the test objects required to select a laptop and add it to your cart.

This time, use UFT's Object Spy, which enables you to spy, highlight, and add individual test objects to an object repository.

Do the following:

  1. In the UFT Object Repository Manager, select FileNew, and then File > Save As.

    Save your object repository as SelectLaptop.tsr, in the WebTutorial directory.

  2. In the Object Repository manager toolbar, click to open the Object Spy. In Chrome, ensure that the AdvantageDEMO site is open.

    In the Object Spy, click the pointing hand button. UFT is minimized to display Chrome.

  3. In Chrome, use your cursor to locate the Link object that highlights the LAPTOPS link on the bottom left. Ensure that the entire image is highlighted.

    The Object Spy shows the properties for the LAPTOPS link object.

    For example:

  4. Click the highlighted LAPTOPS image to have the Object Spy capture the Link : LAPTOPS Shop Now test object properties.

  5. In the dropdown list under the Object Spy toolbar, ensure that your new SelectLaptop.tsr object repository is selected.
  6. Enlarge the Object Spy dialog to see the full path. Then, click the Add Object to Repository button to add the new object to the repository.
  7. Repeat the steps above to add the following objects to the SelectLaptop object repository using the Object Spy.

    Click the links to expand for details:

Your object repository should now look like this:

Tip: The Object Spy is available from both the Object Repository toolbar, and the main UFT toolbar. For more details, see Use the Object Spy.

Associate your new object repository with the SelectLaptop action

Do the following:

  1. In UFT's Solution Explorer, right-click the SelectLaptop action, and select Associate Repository with Action.
  2. Select the SelectLaptop.tsr file, and click Open.
  3. In the message box that appears, click Yes.
  4. Save your test.

Back to top

Create a Checkout object repository

Create an object repository with the test objects required to check out your cart and complete your purchase.

Create a new object repository and add your first object

  1. In the UFT Object Repository Manager, select FileNew, and then File > Save As.

    Save your object repository as Checkout.tsr, in the WebTutorial directory.

  2. In Chrome, click the ADD TO CART button to add the HP CHROMEBOOK 14 G1(ENERGY STAR) to your cart.

    Then, use the Object Spy to spy and add a test object for the cart icon Link object at the top right.

  3. Make sure that the new Checkout.tsr object repository is selected, and then click Add Object to add the new object to the repository.

    The cart link test object is simply named 1.

Navigate and Learn to add more test objects

Use the Object Repository's Navigate and Learn toolbar to learn the additional objects required for this action.

Do the following:

  1. In your browser, click CHECKOUT to display the SHIPPING DETAILS page.

  2. In the UFT Object Repository Manager, select Object > Navigate and Learn to open the Navigate and Learn toolbar.

  3. Define the learn filter to determine the objects you want to add to the repository.

    On the Navigate and Learn toolbar, click the filter button , and then select All object types.

    This configures UFT to learn all the objects on the selected page.

  4. Select your browser window. Then, in the Navigate and Learn toolbar, click Learn to learn all the objects on the SHIPPING DETAILS tab.

    The browser window flickers as UFT adds test objects to the Checkout.tsr object repository.

  5. In Chrome, click NEXT to display the PAYMENT METHOD tab.

    Ensure that the SafePay option is selected, and click Learn again to learn all the objects on the PAYMENT METHOD tab.

  6. Enter values in the SafePay username and Password fields, and then click PAY NOW to continue on to the ORDER PAYMENT order confirmation page.

  7. In the Navigate and Learn toolbar, click Learn again to learn all the objects on the page.

  8. Close the Navigate and Learn toolbar and save your object repository.

    Your object repository should now look like this:

  9. Associate your new object repository with the Checkout action, and save your test.

    For details, see Associate your new object repository with the SelectLaptop action.

Back to top

Create a Logout object repository

Create a repository with the test objects used to log out of your AdvantageDEMO account.

Do the following:

  1. In the UFT Object Repository Manager, select FileNew, and then File > Save As.

  2. Save the object repository as Logout.tsr, in the WebTutorial directory.
  3. Open and use the Object Spy to add a test object for the USER menu at the top right.

    In the Object Spy, make sure the select the Logout.tsr file from the dropdown list. Then, click the Add to Object Repository button to add your new test object to the Logout repository.

    For example:

  4. In the Object Spy, click the pointing hand again to add the Sign Out link in the menu.

    Do the following:

    • Press the CTRL button on your keyboard to pause the spying, and then click the USER icon again.

    • Release the CTRL button, and hover over Sign out in the USER menu.

  5. Click the item to capture the object properties, and then on it, and then click the Add to Object Repository button to add the Link: Sign out test object to the Logout.tsr repository.

    The Logout object repository now has the two test objects required to sign out of the AdvantageDEMO site.

  6. Save the object repository, and then switch back to UFT.

  7. Associate your new object repository with the Logout action, and save your test.

Each of your test actions now has its own shared object repository, viewable from the Solution Explorer.

Back to top

Next steps: