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
Click the image to enlarge it.
|
WebSocket Server Messages
Click the image to enlarge it.
|
Scenario
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
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 .
-
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.
-
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 & or < ) 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 data replacerTo create a data replacerYou can create a data replacer using a wizard or manually.
Important Notes
-
Before you create a data replacer, create a variable that will store the value to be inserted. The variable can contain data extracted from a previous response, generated data, or data loaded from an external data source.
- Creation of data replacers for the entire scenario with the wizard is not supported. You can create data replacers on the scenario level manually.
To create with a wizard:
-
Right-click anywhere within the Data Replacers list and then click Create data replacer with wizard. The Create Data Replacer wizard will appear. The wizard will assist you in creating data replacers.
-
Follow the wizard instructions to create a data replacer. LoadComplete will add the data replacer to the list.
-
In the Variable column, specify the variable whose value LoadComplete will insert in the request. You can either type the variable name or click and select the needed variable in the resulting dialog.
To create manually:
-
Right-click anywhere within the Data Replacers list and then click New Item. This will add a new row to the replacer list.
-
In the Area column, select where in the request the data to replace is located: header, body or cookie.
-
In the Expression column, enter the needed regular expression, or parameter name, or cookie name.
-
If the Expression column specifies the regular expression, enter the index of the needed subexpression to replace in the Attributes in the $number
format. To replace the whole expression, enter $0
. See Working With Subexpressions.
For cookie replacers, enter the cookie attributes (if needed). See Cookie Replacer Attributes.
-
In the Variable column, specify the variable whose value LoadComplete will insert in the request. You can either type the variable name or click and select the needed variable in the resulting dialog.
To create a correlation rule
To create a correlation ruleTo create a correlation ruleYou can create a correlation rule from a replacer you created earlier in the Data Replacers panel. LoadComplete will apply this rule automatically later when correlating response and request data:
-
Check the Rule column value of the desired replacer, it should be User. Creating a rule for other replacer types is meaningless.
-
Right-click the replacer and select Create Rule from the context menu:
Click the image to enlarge it.
LoadComplete will create a correlation rule and will add it to other rules that you can see in the Tools > Options > Recording > Data Correlation settings. The new rule will be in the Converted section of that dialog:
Click the image to enlarge it.
To edit a data replacer
To edit a data replacerTo edit a data replacer
-
Right-click the desired cell and choose Edit from the context menu.
– or –
Click the desired cell and press F2.
– or –
Click a cell to select it, and then click the cell again.
Note: |
You cannot edit the “Rule” column. LoadComplete sets its value automatically. |
-
Enter the needed data.
-
Press Enter to confirm the change, or press Esc to cancel it.
To delete a data modifier
To delete a data modifierTo 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