Using Variables in Requests

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

About

In LoadComplete, you can use variables to replace recorded data in requests with data extracted from preceding responses or with data that LoadComplete generates or gets from external files.

You can insert variables in various parts of requests:

  • Request URLs.

  • Request header fields.

  • URL parameters.

  • HTML form fields in POST requests.

  • Parameter values in JSON, XML, AMF and other Rich Internet Application requests,

  • Body of textual POST requests and WebSocket messages.

We recommend that you select a variable whose data type matches the parameter data type. If LoadComplete fails to convert the variable value to the parameter data type, the test server may raise an error.

Refer to a variable

To refer to a variable within the request contents, enter the variable name in the following format:

@VariableName

You can use variables only to specify the whole value of a parameter. You cannot use it to specify part of a parameter value and to concatenate variable names.

Notes:

  • If you have a project variable and a scenario variable with the same name, LoadComplete will use the scenario variable during simulation.

  • Variables defined in a subscenario can be accessed from the main scenario that calls the subscenario and from other subscenarios that the main scenario calls.

    If several subscenarios define a variable with the same name, LoadComplete will use the variable defined last.

  • Make sure your variable names do not include names of other variables (for example, MyVariable and MyVar). Otherwise, LoadComplete may fail to distinguish such variables when you insert them into the request header or body.

  • In the Expression column of data selectors and data replacers, you can refer to variable using this syntax:

    \vVariableName\v

    It enables you to concatenate a variable with another variable or string data to get the final expression:

    some-data\vVariable1\vmore-data\vVariable2\vdata3

More info on using variables

Related topics of interest

See Also

Specifying Appropriate Request Data
Preparing Test Data
About Validating Response Contents

Highlight search results