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 accessible 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 One 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\UFT One\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.

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 One's Object Identification Center, which enables you to spy, highlight, and add test objects to an object repository.

Do the following:

  1. In the UFT One 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 Identification Center (OIC). In Chrome, ensure that the AdvantageDEMO site is open.

  3. In the OIC, toggle on the Multi-object Spy switch and click the Start spying button .

    The OIC window is replaced by the OIC widget , the cursor is changed to a hand , and UFT One is hidden.

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

    For example:

  5. Click the highlighted LAPTOPS image to have the OIC capture the LaptopsCategory test object properties.

    Press CTRL to change the hand to a regular Windows cursor so that you can stop spying and interact with the app. Click on the text LAPTOPS to open the LAPTOPS page.

  6. Release the CTRL button to continue spying on the HP CHROMEBOOK 14 G1(ENERGY STAR) WebElement object. Click on its text in order to capture the properties.

    Press CTRL to change the hand to a regular Windows cursor so that you can stop spying and interact with the app. Click on the text HP CHROMEBOOK 14 G1(ENERGY STAR) to open the details page.

  7. Release the CTRL button to continue spying on the ADD TO CART button object. Click it to capture the properties.

  8. Now your OIC window should show the following three captured objects:

    Hover over an object and click the Edit button to view the object properties.

  9. Click the down arrow next to Add Object button, and ensure that your new SelectLaptop.tsr object repository is selected.

    Note: If you haven't created a SelectLaptop.tsr object repository, click New Object Repository. In the dialog box that opens, browse to the C:\Users\<user>\Documents\UFT One\WebTutorial directory and enter SelectLaptop in the File name field.

  10. Click Add Object to add all spied objects to the repository.

Your object repository should now look like this:

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

Associate your new object repository with the SelectLaptop action

Do the following:

  1. In UFT One'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 One Object Repository Manager, select FileNew, and then File > Save As.

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

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

    Then, use the OIC to spy on 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 ShoppingCart.

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 One 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 Default object types.

    This configures UFT One to learn the default 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 One adds test objects to the Checkout.tsr object repository.

  5. Click NEXT to display the PAYMENT METHOD tab. (Make sure to first add the NEXT button to the repository).

    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 One 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 OIC to spy on the USER menu at the top right.

    In the OIC, make sure to select the Logout.tsr object repository in the Add Object dropdown list. Then, click Add Object to add your new test object to the Logout repository.

    For example:

  4. In the OIC, click the OIC widget to spy on the Sign Out link.

    Do the following:

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

    2. Release the CTRL button, and click Sign out in the USER menu.

  5. Click Add Object in the OIC to add the 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. The object names may differ, depending on your unique test parameters, such as user name.

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

  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

Rename objects in the object repository

This exercise illustrates how to rename objects in the repository. This is ideal for creating meaningful object names that can make your scripts more readable and user-friendly.

Do the following:

  1. Go to the Logout action.

  2. Right-click the UserMenu object and select Rename.

  3. Change the object name to msanchez.
  4. Note the two objects.

Back to top

Next steps: