Define a visual relation identifier for a test object - Use-Case scenario

Relevant for: GUI tests and components

This scenario describes the process you would follow to define a visual relation identifier for a specific test object that would otherwise require the use of ordinal identifiers.

Note: For a task related to this scenario, see Maintain test objects in object repositories.

Background

  • The application you are testing contains three identical instances of the Candidate object.

  • When UFT learned the objects in the application, it assigned an ordinal identifier to each Candidate test object.

  • For the purpose of this exercise, Object #1 and Object #9 make up an object pair, which is always to the left and right of the Candidate object to identify. You want to instruct UFT to identify the instance of the Candidate object that is located between the Object #1 and Object #9 object pair during every run session, even if the sorting order of the object pairs changes between run sessions.

Back to top

Open the Visual Relation Identifier dialog box

  1. In UFT, open the relevant object repository and select the Candidate test object to identify.

  2. Verify that you have selected the correct test object by selecting View > Highlight in Application, and making sure that the correct object is highlighted in the application.

  3. In the Visual Relation Identifier Settings row of the Object Repository window or Object Properties dialog box, click in the Value cell.

Back to top

Highlight the objects that match the test object's description

In the Visual Relation Identifier dialog box, click the Preview button. This instructs UFT to highlight all objects that match the test object description (ignoring the ordinal identifiers). The main UFT window is hidden, and each instance of the Candidate object in the application is highlighted, including the instance of the test object you want to identify.

Click the Preview button again to restore the UFT window.

Back to top

Define the first related test object using horizontal visual relations

  1. In the Related Objects area, click the Add button. The Select Test Object Dialog Box opens, enabling you to either select a test object from the object repository, or add an object from the application.

    For the purpose of this scenario, the first related test object is Object #1, which is located to the left of the Candidate object in the application.

  2. In the Relation Details area, select the first checkbox and then select Left from the drop-down list. The description area displays a summary of the visual relation identifier.

  3. To verify that the visual relation is defined correctly, click the Preview button again. The main UFT window is hidden, and the visual relation identifier displays the objects that match the test object's description, including the currently defined visual relation. It also highlights the selected related object, and a visual representation of the defined relation details. Since Object #1 is to the left of all three Candidate buttons, all three buttons are still highlighted when you use the Preview button.

Back to top

Define the second related object using vertical visual relations

  1. In the Related Objects area, click the Add button. The Select Test Object Dialog Box opens, enabling you to select or add another object.

    For the purpose of this scenario, the second related test object is Object #5, which is located above and vertically in line with the Candidate object.

  2. In the Relation Details area, select the second check box. From the drop-down list select Above, and then select the In line (vertically) checkbox. The description area displays a tooltip of all the selected visual relations.

  3. To verify that the visual relations are defined correctly, click the Preview button again. Since Object #5 is above all three Candidate objects, all three are still highlighted. That means you still need to select another related object to create a visual relation identifier that uniquely identifies your object.

Back to top

Define the third related object using distance visual relations

  1. In the Related Objects area, click the Add button. The Select Test Object Dialog Box opens, enabling you to select another test object.

    For the purpose of this scenario, the third related test object is Object #9, which is the closest object to the right of the Candidate object.

  2. In the Relation Details area, select the third checkbox and then select Closest on the Y-axis from the drop-down list. The description area displays an updated summary of the visual relation identifier.

  3. To verify that the visual relations are defined correctly, click the Preview button again. you can now see that this third related object enables UFT to uniquely identify the correct object.

Back to top

Results

After you finish defining all of the necessary visual relations:

  • The desired Candidate object is the only object in the application that is identified when you use Preview.

  • UFT can now correctly identify the desired Candidate object during every run session, even if the user interface changes, as long as the Candidate object maintains it's relative location to the three related objects you defined.

  • The Ordinal Identifier property is disabled in the Object Repository Manager or window.

Back to top