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

CSV variables allow you to retrieve values (logins, passwords or product IDs, and so on) to be used in scenarios from CSV (comma-separated values) and text files. Unlike list variables that are linked to a static value list, CSV variables are linked to a data field in an external CSV file. Since values are stored apart from your test project, there is no need to modify the project when you need to add or remove values.

Each CSV variable also defines the order in which different virtual users access values from the list. For example, you can configure the variable so each virtual user can use only one specific value from the file or each virtual user can access the file sequentially and take the next value every time it simulates a request to the server.

You can use CSV variables to specify query string parameters of GET requests, as well as form fields sent via POST requests, for example:

GET /find/?first=@FirstName&last=@LastName HTTP/1.1

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.

Depending on the value access type specified for the list, different virtual users will be able to play back the parameterized request using different parameter values, for example:

GET /find/?first=John&last=Smith
GET /find/?first=Susan&last=McLaren
GET /find/?first=Charles&last=Dodgeson
and so on

This way, the behavior you will get is more realistic than that when using the same recorded value for all virtual users.

For more information on using variables in requests, see About Variables.

About CSV File Format

Although CSV stands for comma-separated values, the text data source can use different value separators - semicolons, tabs, spaces and other characters. LoadComplete allows specifying the desired separator when creating a CSV variable. For this purpose, use the Delimiter field of the CSV File page.

Parameters

You create and modify CSV variables using a wizard that assists you with filling in and verifying variable parameters. The wizard includes the following pages:

CSV File Page

Name

The variable name that will be used to refer to this variable in request parameters. The name can include letters (A..Z, a..z), digits (0..9) and underscores ( _ ) and must be unique within the project.

File name

The fully-qualified name of the CSV file. The file can be stored on the local computer (for example, C:\Tests\Data.csv) as well as in a network share (for example, \\Server\SharedFolder\TestData.csv). The latter is recommended if you are going to copy or move your test project to other computers -- in this case, the CSV file name will be computer-independent.

CSV files typically have the .csv or .txt extension, but other extensions are also possible.

First line contains column names

Select this option if the first line in the CSV file is used as a header and specifies custom names for data fields. This will instruct LoadComplete to use values from the first line as field names. Otherwise LoadComplete will use the default field names - F1, F2 and so on.

Delimiter

Specifies the character that is treated as a separator for values stored in the selected CSV file. The Delimiter field allows entering any character except for the quotation mark ("). The quotation mark is an invalid separator and you cannot specify it in the Delimiter field.

Specify Column and Selection Type Page

Column

The name of the data field that the variable will retrieve values from. You can enter the field name manually or select it from the drop-down list.

Value access type

The order in which the variable will return values from the selected Column:

  • Item index equals virtual user index - Each virtual user uses the row with the same index as the user’s global index. (This index is calculated based on the order of user groups defined in the test and the user’s index within the group.) For example, the first virtual user uses the first value from the column, the second user - the second value, and so on. The variable has the same value in all requests made by the given virtual user.

    Tip: Use this option for user names, passwords and other kinds of values that should be unique for each virtual user used in the test.

    Show Example

  • Item index equals virtual user index within a station - In this case, each workstation has its own copy of the variable and the data. Each virtual user uses the row with the same index as the user’s unique index within the station. (This index is calculated based on the order of user groups defined for that station and the user’s index within a group.) For example, the first virtual user on the station uses the first value from the column, the second user - the second value, and so on. The variable has the same value in all requests made by the given virtual user.

    Show Example

  • Next value on each use - The variable returns the next value from the column on each use by any virtual user on any station. If the variable is used multiple times within the same request, each instance will use the next value.

    Show Example

  • Next value on each use within a station - In this case, each workstation has its own copy of the variable and the data. The variable returns the next value from the column on each use on the given station.

    Show Example

  • Next value on each use by a virtual user - In this case, each virtual user has its own copy of the variable and the data. The variable returns the next value from the column each time the given user accesses it. That is, each virtual user starts by using the first value, then the second value, then the third value, and so on.

    Show Example

  • Random - The variable returns a random value from the column on each use. If the variable is used multiple times within the same request, each instance will have a random value.

Note: Regardless of the selected option, when the variable reaches the end of the column, it repeatedly continues from the beginning of the column.

Preview Data Page

This page displays a preview of the selected CSV file field. When you run the load test, the variable will return individual values from this field according to the Value access type option.

Remarks

A CSV variable fetches all needed values from the specified file upon the test start:

  • External changes made to the CSV file during the test run will not affect the variable values.

  • If you simulate virtual users on remote stations or on cloud computers, you will not have to configure access to the file from them. Only the computer, from which you control the test run, must have access to the file.

See Also

Excel Variables
Database Variables
List Variables

Highlight search results