Selecting a reference in a response

When a response contains multiple matches for the regular expression that defines a reference, you can select which match is used subsequently as the data source. You can specify a particular occurrence, or you can specify a random occurrence.

About this task

An application under test might return responses that contain multiple matches for a regular expression that defines a reference. For example, a response might contain multiple links to rows of data, where each row represents a different user. You can control which occurrence of the regular expression is used as the data source in subsequent data correlation.

If you edit the Regular Expression that is associated with a reference, and then click Verify or OK, and the new regular expression still connects to the highlighted string in the preview window, then the Specific occurrence number is updated automatically, overwriting any changes.

Procedure

  1. In the Test Navigator, browse to the test, and double-click it. The test opens.
  2. Locate the response that contains the reference that you want to specify.
  3. In the Content field under Test Element Details, right-click the reference, and then select Properties.
  4. Optional: To edit the regular expression that is used to locate the reference, click the Toggle regular expression assistant push button on the Properties window. The regular expression assistant displays the response content that is matched by the regular expression and the groups that are captured by the regular expression.
    Note:

    If an HTTP response is JSON, you can create a reference of that JSON value and use the JSON expression. You can select the JSON value, right-click the value, and then click Create Reference to create a reference. The Regular Expression field in the Reference dialog box displays the JSON expression instead of the regular expression.

    You can also verify the same from the reference Properties dialog box after the reference is created. From the test editor, select and right-click the JSON value that is highlighted in dark blue color, and then select Properties to open the Reference dialog box. You can see that the Regular Expression field displays the JSON expression.

  5. On the Properties page for the reference, select which Occurrence to use as the data source. By default, the first occurrence of a match for the Regular Expression is used as the data source.
    • To specify a particular occurrence, select Specific occurrence number, and then type the number of the match. For example, type 4 to specify the fourth match of the regular expression in the response.
    • To specify a random occurrence, select Random occurrence.
    • To specify the last occurrence, select Last occurrence.
  6. Click OK.
    The occurrence that you specified is used as the data source for data correlation when you run the test.