Creating Data Replacers

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

To create a data replacer:

  1. Create a variable that will store the value you want to insert into your request:

    • To create a project variable that will store a value extracted from an external data source or generated by LoadComplete, use the Variable wizard.

    • To create a scenario variable that will store data extracted from an earlier response, define a rule that will extract the data. See Extracting Data From Responses. LoadComplete will create the variable to store the extracted data automatically.

      If you have a project variable and a scenario variable with the same name, the data replacer will use the scenario variable.
  2. (Optional.) If needed, create a variable that will contain an expression defining the data fragment to replace.

  3. Specify where you want to insert data:

    • Request headers

    • Request cookies

    • Bodies of POST requests

    • Content of WebSocket client messages that pass text information

    • Content of Rich Internet Application (RIA) requests

  4. To insert data to an individual request, select it in the Scenario Explorer and switch to the Data Replacers tab:

    Data Replacers Tab of a request

    Click the image to enlarge it.

    To insert data to all requests in a scenario, select the top-level Scenario node and then switch to its Data Replacers page:

    Data Replacers Tab of a scenario

    Click the image to enlarge it.

  5. Create a new data replacer:

    To replace data in an arbitrary place in the request’s body or header
    1. Right-click within the tab and then click Create data replacer with wizard. This will call the Create Data Replacer wizard that helps you create data replacers.

      Creation of data replacers for the entire scenario with the wizard is not supported. To learn how to create a data replacer manually, see below.
    2. Follow the wizard instructions to create a data replacer that LoadComplete will use for replacing data in the request.

    3. The wizard will create a data replacer and add it to the replacers list.

    — or —

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

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

    3. In the Expression column, enter the data to be replaced or a search pattern. If necessary, you can use a regular expression.

      You can also specify a variable containing the search pattern. Use the following syntax:

      \vVariableName\v
      – or –@VariableName

      If you need to concatenate a variable value with another variable or data, use the \vVariableName\v format:

      data1\vVariable1\vdata2\vVariable2\vdata3

      @VariableName values cannot be concatenated.

    4. If the specified regular expression matches a large piece of data, you can use subexpressions to clarify the portion of data to be replaced. In the Attributes column, enter the index of the needed subexpression in the $number format, where number is the subexpression position in the regular expression.

    For information on supported expressions, see Regular Expressions Syntax.

    Data Replacer's Search Pattern

    Click the image to enlarge it.

    To replace a parameter value on a web form or in a Rich Internet Application request
    1. Right-click within the Data Replacers tab and then click New Item. This will add a new row.

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

    3. For a web form, enter the parameter name in the Expression column. For example, ctl00%24MainContent%24username. You can find the parameter name on the Request Body panel of the recorded request.

      For a Rich Internet Application request, enter the full name of the request parameter, starting from the top-level node. For example, Message[1]/[1]/clientID. You can find the parameter path in the Path column of the Request Body panel of the recorded request.

      You can also specify a variable containing the needed parameter name. Click and select the needed variable in the resulting dialog, or enter the variable name manually, in the @VariableName format.

    Note: You can also insert the needed variable to the web form or Rich Internet Application request directly on the Request Body page. See Inserting Variables in Rich Internet Application Requests and Inserting Variables Into Web Forms.
    To replace a request’s header parameter
    1. Right-click within the Data Replacers tab and then click New Item. This will add a new row.

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

    3. In the Expression column, enter the path to the request’s URL parameter you want to replace. You can find the needed path in the Request Header panel.

      You can also specify a variable containing the needed parameter name. Click and select the needed variable in the resulting dialog, or enter the variable name manually, in the @VariableName format.

    Note: You can also insert the needed variable in the request’s header directly on the Request Header panel. See Inserting Variables Into URLs and Inserting Variables Into Request Header Fields.
    To insert a cookie
    1. Right-click within the Data Replacers tab and then click New Item. This will add a new row.

    2. In the Area column, select Cookie.

      Note: For setting cookie values, we recommend using Cookie in the Area column rather than Header (Path) or Header (RegExp).
    3. In the Expression column, enter the cookie name. You can also click and select a variable containing the needed cookie name, or specify the variable name manually, in the @VariableName format.

    4. In the Attributes column, enter the cookie’s attributes (if needed). See Cookie Replacer Attributes.

    Cookie Replacer's Name

    Click the image to enlarge it.

  6. In the Variable column, select the variable whose data you want to insert.

    New Data Replacer in the Editor

    Click the image to enlarge it.

    Note: LoadComplete automatically adds the @ prefix to the variable name, if you forget about this.
  7. Select File > Save from LoadComplete main menu to save the changes.

When you simulate the scenario, LoadComplete will use the specified criteria to find the data in a request (or requests) and replace it with the variable value.

See Also

Regular Expressions Syntax
Extracting Data From Responses
Using Variables
About Data Replacers
Editing Recorded Requests

Highlight search results