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

You use data selectors to extract data from a server response’s body, headers, or cookies.

About Data Selectors

A data selector is a rule that LoadComplete applies to server responses during the scenario simulation. LoadComplete saves the data that matches the rule to a variable. You can then use the extracted data to:

Note: LoadComplete can apply data selectors only to responses that return data in textual form.

LoadComplete cannot apply data selectors to binary data types.

To view data selectors defined for a response:

  • Open your scenario for editing. To do this, double-click the scenario in the Scenarios collection in the Project Explorer.

  • In the Scenario Explorer, select the needed request.

  • Switch to the Response page (for HTTP traffic) or the WebSocket Message page (for WebSocket traffic) and select the Data Selectors tab at the bottom of the page.

The Data Selectors tab shows a list of data selectors applied to the response.

Creating Data Selectors

You can configure LoadComplete to create data replacers and data selectors for dynamic parameters and cookies in your scenarios automatically:

  • In the Data Correlation Options dialog, make sure that the correlations rules for dynamic parameters, for which you want to create data selectors, are enabled.

    To create cookie selectors, make sure that the Common/Cookie rule is enabled.

    If needed, create custom correlation rules.

  • After you finish recording a scenario, LoadComplete will show the Correlate Request and Response Parameters wizard. (You can also call the wizard any moment at design time by clicking on the Scenario editor’s toolbar.)

    Command the wizard to correlate the scenario.

  • The wizard will analyze requests and responses in the scenario, and will create data selectors and data replacers for dynamic parameters and cookies it will find.

You can also create custom data selectors in the Scenario editor to extract needed data from requests. For information on how to do this, see –

Creating and Using Data Selectors

Data Selector Alternatives

Data selectors is a powerful and universal solution for protocols that pass data in the textual form. However, if you need to extract data that match some complex pattern, you have to be familiar with regular expressions. In some cases, it is much easier to use other approaches.

If you are testing a SOAP or JSON application, LoadComplete can access individual values in response bodies. To extract response data, store the needed value to a variable. See Extracting Values From RIA Responses.

Data Selector Examples

For examples that show how you can use data selectors to extract data from various areas of responses, see Data Selectors - Examples.

Remarks

  • If the response contains several fragments that match the regular expression, the data selector will capture the first match.

  • If the regular expression does not match anything in the response contents, LoadComplete will not create the data selector and will log the error “Failed to extract any value for the variable variable_name”.

  • The extracted value may include HTML entities (like  , & < and so on) or URL-encoded characters (like %20, %2B, and others). These characters may cause problems for the tested server and you may need to convert them to a needed format. You can do this by using the Convert attribute of the data selector. See Converting Correlation Data for detailed information.

  • If you use the extracted data for data correlation, LoadComplete will wait for the server to return the response containing the needed value until the correlation timeout expires. See About Data Correlation.

  • Сhanging the area type of an existing data selector from Body(RegExp) or Header(RegExp) to any other (Cookie, Body(Path) or Header(Path)), clears the data selector’s attributes.

See Also

Creating and Using Data Selectors
Working With Subexpressions
How to Determine What Data a Selector Extracts
Data Selectors - Examples
Regular Expressions Syntax
About Data Correlation

Highlight search results