Searching and replacing text in tests

With the Test Search function, you can search for text in a test or search within specific test elements, and optionally replace them.

Procedure

  1. In the Test Navigator, browse to the test and double-click it. The test opens.
  2. Right-click the test name, and then select Test Search.
  3. In Search for text, type the text to locate.

    You can leave this field blank, depending on your search strategy. For example, if you know that a string occurs in elements or element instances that you are not interested in, using the options described in steps 4, 6, and 8, you can locate the elements or element instances of interest before entering the search text into this field.

  4. If you have selected pages or requests within the test, click More Options, and then select Restrict search to elements highlighted in Test Contents. This restricts the search to the selected pages and requests.
  5. To perform a case-sensitive search, select Case sensitive. To search with regular expressions, select Regular expression. In regular expression mode, type Ctrl-Space in Search for text for content assistance. Content assistance lists the regular expression patterns and the content that they match.
  6. To highlight found elements in the Test Contents area, click More Options, and then select Highlight found elements in Test Contents. You can use this option with the option described in step 4 to designate the element instances of interest before specifying the text of interest.
  7. To have the search include children of the selected element, click More Options, and then select Recursive. This option is selected by default. If Recursive is cleared, then only the selected element is searched.
  8. In the Elements to search list, select all test elements to search.

    Selecting the check box in step 4 restricts the elements that you can select in this step to the instances that are selected in the Test Contents area. For example, if you select HTTP Pages here and only one page is selected in the Test Contents area, only that page is found. If the check box in step 4 is cleared, every test page is found.

  9. Optional: Click selected elements to define how to search them.

    A new area opens, where you can define how to search a selected element.

    To locate items, continue to the next step. To replace found strings, click Replace and go to step 12.

  10. Click Search. The results of your search are displayed in two views
    • The Search view, which lists the objects that contain matches
    • The Test Search Match Preview view, which displays the matches that were found
    The following figure shows the Search view. URL: Offset: 36 and URL: Offset: 85 designate objects in which the search text was found.
    Search results page
  11. In the Search view, complete any of these search actions:
    • To preview a found string in the Test Search Match Preview, click the object.
    • To open your test at the location where an instance is found, double-click the object.
    • To perform a different search action (such as proceed to the next match or previous match, replace), right-click the object, and select your choice.
  12. If you clicked Replace in step 9, the Replace window opens. In the With field, type the replacement text.
    Replace dialog box
  13. Select the replacement action by clicking the appropriate button. If you are making selective replacements, found instances are displayed in the same order as in the Test Search Match Preview view. Click Replace or Skip until all found instances have been displayed.

Feedback