Modifying the property used to identify an object in a test script

When a test is recorded, the property that is used in the test to identify a graphic object might be inaccurate and cause the step to fail during playback. You can modify an object property and its value, as well as the operator, to improve test robustness.

About this task

You can change the value of the default identification properties for the UI controls.
Note: For the XPath default identification property that is used for UI controls, its value is calculated automatically when recording the test, and all operators are compatible with this identification property. XPath property can be modified but with some limitations: if the XPath value is modified with a value that is not captured when recording the test, the Screen capture is not highlighted in the Mobile Data View and only 'equals' operator is accepted, no other values or regular expressions can be used.
You can also replace a generated text property with an image property to identify a target object. For details about object recognition in mobile and web UI tests, see Improving test script robustness.

Procedure

To modify an object property, you can use one of the following methods: drag and drop, copy and paste, or the context menu.

  1. Click a step in the script. The object captured during the recording of this test step is highlighted in the Mobile and Web UI Data view.
  2. In the Properties table of the Mobile and Web UI Data view, select a relevant property. Click the View main property only icon View main property only in the filter tool bar to see the main properties displayed in bold, or click the View verifiable property only icon View verifiable property only.
  3. Drag the property to the Object Identified by field in the test editor. Or, right-click the property in the table and select Copy, then Paste in the Object Identified by field. Another method is to right click a property in the table, and select Identify step target using property.

    A menu item is available for each candidate property in the context menu of the Screen Capture view (see Figure 2). If the newly selected property is inappropriate, a message warns you that object recognition may be broken. The property name and its value are replaced in the Object identified by fields.

    When the test is recorded, the default operator for identifying an object in a test run is ‘equals’ but there are many other operators that you can use to identify objects in a mobile or web UI application. They can be used for verification points in a test to verify an attribute, for example. See Creating verification points from the Mobile and Web UI Data view and Creating verification points in a test.

    Figure 1. Modifying the object property and value from the Properties context menu
    Here you modify an object property and value with the context menu 'Identify step target using property class'
    Figure 2. Modifying the property and value of an object captured during the test recording with a candidate property from the Screen Capture context menuModifying the property generated for the object captured during recording with a candidate property from the screen capture's context menu
  4. Save and run the test to verify that the object is identified.
Feedback