Recording Locators Using the Locator Spy

This functionality is supported only if you are using the Open Agent.

Use the Locator Spy to record the locator of a specific object in your application under test. You can then copy the locator to the test case or to the Clipboard.

  1. Configure the application to set up the technology domain and base state that your application requires.
  2. Click File > New. The New File dialog box opens.
  3. Select 4Test script and then click OK. A new 4Test Script window opens.
  4. Click Record > Window Locators. The Record Locator dialog appears.
  5. From the Application State list box, select DefaultBaseState to have the built-in recovery system restore the default base state before the test case begins executing.
    • If you choose DefaultBaseState as the application state, the test case is recorded in the script file as testcase testcase_name ().
    • If you choose another application state, the test case is recorded as testcase testcase_name () appstate appstate_name.
  6. Click Start Recording. Silk Test Classic performs the following actions:
    • Closes the Record Locator dialog box.
    • Starts your application, if it was not already running. If you have not configured the application yet, the Select Application dialog box opens and you can select the application that you want to test.
    • Removes the editor window from the display.
    • Displays the Recording window.
    • Waits for you to take further action.
  7. Position the mouse over the object that you want to record. The related locator XPath query string shows in the Selected Locator text box. The Locator Details section lists the hierarchy of objects for the locator that displays in the text box.
    Note: If you are testing on a browser, the Selected Locator field displays the locator only when you actually capture it.
  8. Perform one of the following steps:
    • Press Ctrl+Alt to capture the object. The Locator field displays the XPath query string for the object. You can edit the locator.
    • Press Ctrl+Shift to capture the object if you specified the alternative Record Break key sequence on the General Recording Options page of the Recording Options dialog box.
      Note: For SAP applications, you must set Ctrl+Shift as the shortcut key combination to use to pause recording. To change the default setting, click Options > Recorder and then check the OPT_ALTERNATE_RECORD_BREAK check box.
    • Click Stop Recording Locator to capture the locator that is currently displayed in the Locator field.
    • If you use Picking mode, click the object that you want to record and press the Record Break keys.
    Note: Silk Test Classic does not verify whether the locator string is unique. Micro Focus recommends that you ensure that the string is unique, because otherwise additional objects might be found when you run the test. Furthermore, you might want to exclude some of the attributes that Silk Test Classic identifies because the string will work without them.
  9. Click Validate Locator to highlight the object, to which the locator in the Locator field corresponds, in the test application.
  10. To refine the locator, in the Locator Details table, click Show additional locator attributes, right-click an object and then choose Expand subtree. The objects display and any related attributes display in the Locator Attribute table.
  11. Optional: You can replace a recorded locator attribute with another locator attribute from the Locator Details table. For example, your recorded locator might look like the following:
    /Window[@caption='MyApp']//Control[@id='table1']
    If you have a caption Files listed in the Locator Details table, you can manually change the locator to the following:
    /Window[@caption='MyApp']//Control[@caption='Files']
    The new locator displays in the Selected Locator text box.
  12. Copy the locator to the test case or to the Clipboard.
    • Click Paste Hierarchy to Editor to paste the window declarations that are displayed in the Locator Details into the open Silk Test Classic file.
    • Click Copy Hierarchy to Clipboard to copy the window declarations that are displayed in the Locator Details to the Clipboard.
    • Click Paste Locator to Editor to paste the contents of the Locator field into the open Silk Test Classic file.
    • Click Copy Locator to Clipboard to copy the contents of the Locator field to the Clipboard.
    Tip: If you have copied code to the Clipboard, you can click Edit > Paste in the Silk Test Classic menu to insert the code into the current window at the location of your choice, or even into a different editing window.
  13. Click Close.