Modifying a Locator in an Object Map

Locators are automatically associated with an object map item when you record a script. However, you might want to modify a locator path to make it more generic. For example, if your test application automatically assigns the date or time to a specific control, you might want to modify the locator for that control to use a wildcard. Using a wildcard enables you to use the same locator for each test even though each test inserts a different date or time.

  1. In the Package Explorer, click on the Object Maps folder of the project in which the object map that you want to change is located.
  2. Choose one of the following:
    • Double-click the object map that includes the locator that you want to modify.
    • Right-click the object map that includes the locator that you want to modify and choose Open.
    The object map displays a hierarchy of the object map items and the locator associated with each item.
  3. Navigate to the locator that you want to modify. For example, you might need to expand a node to locate the locator that you want to modify.
  4. Click the locator path that you want to modify and then click the locator path again.
  5. If you have a valid locator path, you can type the item name and locator path that you want to use and then press Enter. To determine a valid locator path, use the Locator Spy dialog box as described in the following steps:
    1. In the Silk4J tool bar, click Locator Spy.
    2. Position the mouse over the object that you want to record and press CTRL+ALT. Silk4J displays the locator string in the Locator text field.
    3. Select the locator that you want to use in the Locator Details table.
    4. Copy and paste the locator into the object map.
  6. If necessary, modify the item name or locator text to meet your needs. If you use an invalid character or locator, the item name or locator text displays in red and a tooltip explains the error.

    Invalid characters for object map items include: \, /, <, >, ", :, *, ?, |, =, ., @, [, ].

    Invalid locator paths include: empty or incomplete locator paths.

  7. Press CTRL+S to save your changes

If any existing scripts use the locator path that you modified, you must manually change the visual tests or scripts to use the new locator path.