Inserting Variables Into URLs

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

In LoadComplete, you can change the URLs of requests to simulate. You can replace URL parameters and arbitrary parts of URLs with variables containing data extracted from preceding responses or data that LoadComplete generates or gets from external files.

Why Inserting Variables into URLs

A URL of a tested web page may contain session or user identifiers. For example, if a web site assigns the id272 identifier to a user session, the request URLs will look like this –

http://mysite/products/cart/id272/

If request URLs in your recorded scenario contains such dynamic values, a test using that scenario most likely will not work correctly when you run it for multiple virtual users. This may happen because all virtual users will have the same ID.

To solve the problem, replace the recorded value in the URL with the variable containing the expected data.

Inserting Variable Values Into Request URL Parameters

  • Open your scenario in the Scenario editor. To do this, double-click the scenario in the Project Explorer.

  • Find the request in whose URL you want to use a variable value and open this request for editing.

  • In the Request Header table of the Request page, expand the Request | Query node and examine the request parameters.

    Request URL with query parameters

    Click the image to enlarge it.

  • Select the needed parameter.

    In the Value column, enter the name of the variable that stores the needed value or click and select the variable in the resulting dialog.

    Parameterized Request URL

    Click the image to enlarge it.

    If you type the variable name, be sure to prefix it with @ (that is, enter @variableName). Else, the editor will consider the variable name as a string.

Inserting Variables Into URLs

  • Open your scenario in the Scenario editor. To do this, double-click the scenario in the Project Explorer.

  • Select the request in whose URL you want to use a variable.

  • Switch to the Request page, if it is not selected.

  • In the Request Header table of the Request page, expand the Request | Path node.

    In the Value column, replace the needed part of the URL with a variable. Add the @ prefix to the variable name, that is, @VariableName:

    Using Variable to Specify Request URL

    Click the image to enlarge it.

Supported Syntax

To insert a variable to a URL, use the @ symbol followed by the variable name: @VarName.

You can use variables to replace:

  • URL paths - parts between the / characters:

    http://mysite.com/products/@Var1

    http://mysite.com/@Var1/products/@Var2

  • Values of query string parameters:

    http://mysite.com/products/browse?sessionid=@Var1&clientid=@Var2

  • Both of the above:

    http://mysite.com/products/@Var1?sessionid=@Var2

You can use several variables to parameterize different parts of a URL:

Using Multiple Variables to Parameterize the URL

The following is not supported. LoadComplete will not insert a variable value into a request:

  • Variables followed by characters other than the separators /, ? and &. Semicolons (;) are not separators:

    http://mysite.com/products/@Var1.aspx

    http://mysite.com/products/@Var1?sessionid=@Var2_TestID&clientid=@Var3

    http://mysite.com/products/@Var1?sessionid=@Var2;clientid=@Var3

  • One variable after another without separators:

    http://mysite.com/products/@Var1@Var2

  • Variables used as the names of query string parameters:

    http://mysite.com/products?@Var1=10

See Also

Extracting Data From Responses

Highlight search results