Creating and Using Data Selectors

Applies to LoadComplete 4.97, last modified on May 20, 2019

Creating a Data Selector

To create a new data selector:

  1. Open your user scenario for editing. To do this, double-click the scenario in the Project Explorer panel. LoadComplete will open the Scenario editor in the Workspace panel on the right.

  2. In the Scenario Explorer, look into the request tree and find the request with the response, whose data you want to extract (if you recorded WebSocket application traffic, find the server message). Open this request (or server message) for editing.

  3. Switch to the Response page of the editor (for HTTP traffic), or to the WebSocket Message or Message Contents panel (for WebSocket server messages). These panels display the contents of the server response.

  4. Examine the response contents to understand what expression to use to extract data.

    To find a cookie you want to extract, examine the Set-Cookie header in the Response Header panel.

  5. Switch to the Data Selectors tab and create a new data selector.

    To extract data from an arbitrary part of the response body or header
    • Right-click within the tabbed page and then click Create data selector with wizard. This will call the Create Data Selector wizard that helps you to create data selectors.

    • Follow the wizard instructions to create a data selector that LoadComplete will use for extracting data from the response.

    • LoadComplete will create a data selector and add it to the selectors list.

    – or –

    • Right-click within the tab and then click New Item. This will add a new row to the Data Selectors tab.

    • In the Area column, select Body (RegExp) or Header (RegExp).

    • In the Expression column, specify the text to be extracted or the search pattern. You can use the regular expression.

    • The regular expression specified for your data selector can match a large piece of data. If necessary, you can use subexpressions to clarify the portion of data to be extracted.

      Subexpressions are part of a regular expression enclosed in parentheses, for example, <value id="[a-z0-9]*" name="myvalue">(.*)</value>.

      In the Attributes column, you specify the subexpression in the $number format, where number is the subexpression position in the regular expression. $1 corresponds to the first subexpression; $2 - to the second one, and so on. $0 corresponds to the entire regular expression.

    To extract data from a Rich Internet Application response
    • Right-click within the tab and then click New Item. This will add a new row to the Data Selectors tab.

    • In the Area column, select Body (Path).

    • In the Expression column, enter the name (with the full path) of the RIA response’s parameter whose value you want to extract. For example, Message[1]/[1]/clientID.

      You can find the parameter path in the Path column of the Response Body page of the recorded response.

    Note: You can save the parameter value to the needed variable directly on the Response Body page. See Extracting Values From RIA Responses.
    To extract a response’s header parameter
    • Right-click within the tab and then click New Item. This will add a new row to the Data Selectors tab.

    • In the Area column, select Header (Path).

    • In the Expression column, enter the path to the needed parameter in the response header. For example, Response/Code.

      You can view the header structure and find the name of the needed header field on the Response Header panel of the recorded response.

    To extract a cookie that a response sets
    • Right-click within the tab and then click New Item. This will add a new row to the Data Selectors tab.

    • In the Area column, select Cookie.

    • In the Expression column, enter the name of the cookie whose value you want to extract.

  6. LoadComplete automatically creates a variable to store the extracted value. You can view it in the Variable column. If needed, specify the desired variable manually - type the variable name (with the @ prefix, for example, @MyVariable), or click and select the variable in the resulting dialog. If the variable does not exist, LoadComplete will create it.

    Note: If you already have a project variable with the same name, LoadComplete will ignore that variable and use the created scenario variable during this scenario simulation.
  7. If the extracted data contains URL-encoded characters (%20, %2B and others) or HTML entities (&amp;, &lt;, &gt; and others), select the desired decoding scheme in the Convert column. This will command LoadComplete to decode data before saving it to the specified variable. For more information on this, see Converting Correlation Data.

  8. Choose File | Save from LoadComplete’s main menu to save the changes.

Further Steps

  • Check whether your data selector works correctly.

    If you created it via the Create Data Selector wizard, you can verify the data selector on the Created Selector Returns the Following Data page of the wizard.

    If you created and modified it without using the wizard:

    • Call the Find dialog.

    • Enter the data selector’s regular expression as a search condition and check whether the dialog will find the data.

    For step-by-step instructions, see —

    How to Determine What Data a Selector Extracts

  • Validate the response by comparing the extracted value against a baseline value:

    • Switch to the Validators tab.

    • Add a new validation rule that will compare the variable to which the data selector extracts data with a baseline value.

    For step-by-step instructions, see —

    Validating Response Contents

  • (Optional) Modify the extracted data, if needed:

    • Add the Set Variable Value operation to your scenario.

    • Configure the operation to set the needed value to the variable that stores the extracted value.

    For more information, see —

    Modifying Correlation Data

  • Insert the extracted value into subsequent requests:

    • Find requests in the recorded traffic that use the extracted data.

    • Replace recorded values with a reference to the variable storing the extracted data.

    • Run the scenario to validate the changes.

    For more information, see —

    Using Variables in Requests

See Also

About Data Selectors
Regular Expressions Syntax
Working With Subexpressions
Converting Correlation Data
Data Selectors Panel

Highlight search results