Data Replacers Panel

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

About Data Replacers

On the Data Replacers panel, you view, create, and edit data replacers – rules that define how LoadComplete will replace data in requests with specified values. A replacing rule includes a search pattern (for example, a regular expression or a parameter name) that defines the request data to replace and a variable that contains the value that will replace the selected data. The variable can store a value extracted from a response received from the tested web server previously, or a value loaded from an external data source.

You can create data replacers for individual requests or WebSocket messages as well as for scenarios. If you create them for a scenario, the test runner will apply the replacers to all the requests and messages in the scenario.

About the Data Replacers Panel

You create, view and edit data replacers in the Data Replacers panel, which you can find in the following project item editors:

Here are sample views of the panel:

HTTP Requests

HTTP Requests - Data Replacers panel

Click the image to enlarge it.

WebSocket Server Messages

WebSocket Client Message - Data Replacers panel

Click the image to enlarge it.

Scenario

Scenario - Data Replacers panel

Click the image to enlarge it.

The source from which a variable takes its value (it can be a response or a project variable) will be listed as the replacer’s child item. You can also view the sources in the Uses Data From panel displayed by default next to the Data Replacers list (see the images above).

You can double-click a response or server message under a replacer to open a data selector that extracts the data from the response.

Columns

Column Description
Rule How the data selector was created:
  • User - The data replacer was created or edited by a user.
  • Rule_Name - The data replacer was created by a correlation rule, where Rule_Name is the name of the rule. (LoadComplete tracks dynamic parameters passed from responses to subsequent requests and creates correlation rules. See Data Correlation).
  • Legacy item - The data replacer was created in a LoadComplete version prior to version 4 and converted to the current format.
Area The part of the request, where the data to be replaced is located:
  • Body (RegExp)

  • Header (RegExp)

  • Body (Path)

  • Header (Path)

  • Cookie

This column is used for HTTP requests only. For WebSocket messages, this column is hidden.

For cookie-related rules, we recommend using the Cookie value in this column rather than Header (Path) or Header (RegExp).

Expression Specifies the search pattern the data replacer will use to find the data to replace. You can enter the search pattern manually, or specify a variable or a combination of variables that form the needed pattern. See below for details. The value you set in this column depends on the operation and on the Area column value.
HTTP requests

The value you specify in the Expression column depends on what you set in the Area column:

  • Body (RegExp) or Header (RegExp)

    Specifies a regular expression that will be applied to the request body or header. (In the latter case, LoadComplete takes the whole header text and applies the regular expression to it). You can specify a complex regular expression that finds a larger piece of data, and use subexpressions (groups) in this expression to point to a smaller piece of data to be replaced. In this case, you have to use the Attributes column to specify the subexpression (see below). For information on the regular expression syntax, see Regular Expressions Syntax.

  • Body (Path)

    Use this for web forms and Rich Internet Application requests. The column specifies the name of the request’s parameter, whose value LoadComplete will replace:

    • For web forms, specify the parameter name, for example, ctl00%24MainContent%24username.

    • For Rich Internet Application requests, specify the full parameter name, starting from the top-level node in the request structure. For example, Message[1]/[1]/clientID.

    Note: You can insert the needed variable into the request directly on the Request Body panel. See Inserting Variables in Rich Internet Application Requests and Inserting Variables Into Web Forms.
  • Header (Path)

    Specifies the request header parameter, whose value LoadComplete will replace. For example, Request/Query/ReturnUrl. You can see the parameter names and hierarchy in the Request Header panel.

    Note: You can insert the needed variable into the request header directly in the Request Header panel. See Inserting Variables Into URLs and Inserting Variables Into Request Header Fields.
  • Cookie

    Specifies the name of the cookie, whose value you would like to change.

WebSocket messages

Same as for the Body (RegExp) area of the HTTP request. See above.

Note on setting the cell value

You can either enter the search expression in the cell, specify a single variable that contains the expression, or specify a combination of variables that form the needed expression.

To specify a variable, use the following syntax:

\vVariableName\v
– or –
@VariableName

To concatenate variable values and data, use the \vVariableName\v syntax, for example:

data1\vVariable1\vdata2\vVariable2\vdata3

Attributes

HTTP requests (Body (RegExp) and Header (RegExp) areas) and WebSocket messages
The Attributes column specifies a subexpression (or group) that points to the smaller piece of data to be replaced. Subexpressions (groups) are part of the regular expression enclosed in parentheses, for example:

<field name="title">(.*?)</field>

The Attributes value should specify the subexpression in the format $number, where number is subexpression position (from 1) in the regular expression. $1 matches the first subexpression (group), $2 matches the second subexpression and so on. $0 matches the data returned by the entire regular expression. For more information on using the Attributes column, see Working With Subexpressions.

HTTP requests (Cookie area)
The Attributes column specifies parameters like Secure or Expired to be added to the cookie. See Cookie Replacer Attributes.

Body (Path) and Header (Path) areas
LoadComplete ignores the Attributes column.

Variable The name of the variable whose value will be inserted into the request.
Note: If a variable does not exist, LoadComplete will simply remove the value selected by the regular expression.
Convert Specifies whether LoadComplete will re-format the variable value before inserting it into a request. For instance, you may want to replace spaces and commas in the value with appropriate URL-encoded substrings (like %20 and %2B), or replace HTML entities (like &amp; or &lt;) with their textual presentation. You choose the decoding or encoding format from the drop-down list. For more information on conversion, see Converting Correlation Data.
Note: LoadComplete will apply scenario-level data replacers to all the requests in your scenario.

If it applies a data replacer that modifies the request body content (with the Body (RegExp) area) to a GET request, the resulting request may have a non-empty payload. HTTP/1.1 specification does not recommend using GET requests with a non-empty payload body (to learn more, see Section 4.3.1 of RFC 7231). Your tested web server may reject such a request, or return an unexpected response.

To avoid possible issues, make sure that the regular expression of your scenario-level data replacer matches data only in the needed requests. As an alternative, instead of using scenario-level data replacers, create individual data replacers only for requests whose data you want to modify.

Creating, Editing, and Deleting Replacers

To create a data replacer

To create a correlation rule

To edit a data replacer

To delete a data modifier

More on Data Replacers

Related Topics of Interest

See Also

Regular Expressions Syntax
About Data Replacers
Request Operation
WebSocket Connection Operation
Data Selectors Panel
Scenario Editor - Common Tasks

Highlight search results