Create and link a CSV variable to login information
This procedure involves two distinct steps:
-
Creating and correctly configuring a variable that will take its values from a CSV file.
-
Linking the variable to NeoLoad configuration elements so that the variable is used when logging in is required.
When working "manually" with variables in NeoLoad, you must always first declare and define the variable and then link it to the configuration elements.
Create and define a CSV variable
Declaring and using variables is the usual way of achieving dynamic behavior with NeoLoad. A variable can be used in place of constant or static values for many configuration elements. In this example you will use a File Variable, a variable that takes its values from a CSV (Comma Separated Values) file. An alternative would be to use a List Variable and explicitly define the values in the Variables dialog box. This alternative is put aside in this example.
To create and define a CSV variable, follow these steps:
-
Select Variables in the Edit menu.
-
Open the Variable Creation dialog box: Click on the New variable button in the Variable Edition dialog box.
-
Select the type of variable to create: Choose the File type.
-
Enter a name for the variable:
-
Use a meaningful name for the variable. In the example you may have decided to call your variable "account".
-
Browse and select a CSV file.
-
The dialog box displays the first lines of the file so that you can check its contents. The example supposes that the file has been created beforehand and contains consistent values.
-
The file, called
accounts.csv, defines two columns: the first contains the login values, the second contains the associated passwords. The "account" variable has therefore two values automatically named "account.col_0" and "account.col_1". When access to the login values of the "account" variable is required, you will use the${account.col_0}expression. Similarly, when access to the password values of theaccountvariable is required, you will use the${account.col_1}expression. -
NeoLoad assigns default names to the columns of the CSV file. In this case the names of the columns are "col_0" and "col_1" . Columns can be renamed by clicking on the column header and entering a custom name.
-
-
Check the column separator: You can specify a column separator other than the default "
;" character. -
Define in what order the values of the variable will be used:
-
Order can be "Sequential", "Random" or "Any". Using random order can be relevant if, for instance, your application behavior varies depending on the access rights of the logged in user. Using random order, in this case, will better approach a realistic situation. You choose to Take the values randomly.
-
Whether in sequential or random order, once all possible values of a variable have been used, NeoLoad will repeatedly go through all the values again.
-
-
Define when a new value will be used: In this case, you may want a new value to be used each time a Virtual User logs in so you select the For each Virtual User option.
-
Close the Variables Creation dialog box and test your variable:
-
Once you have closed the Variables Creation dialog box you can test the behavior of the "accounts" variable by selecting the Test button in the Variables Editiondialog box.
-
Testing is achieved by choosing different Actions and evaluating the current expression,
${account.col_0}in this case, by selecting the Apply Action and Evaluate button.
-
In the example, choosing the Change Virtual User action will result in a new value for the login column. The value is randomly chosen among the values of the login column. This is consistent with the way you may have defined the accounts variable: you may want a new login value each time the Virtual User changes in the scenario. Testing with other actions, such as the "Change Page action", will not change the value of the variable.
If you wanted to test the password value of the "account" variable, you would change the expression to ${account.col_1}.
At this stage, the "account" variable is ready to be used and tested.
Link the CSV variable to login information
This step involves different procedures depending on the type of authentication your server is using: basic authentication, NTLM authentication or form-based authentication.
Caution: Required steps to link the CSV variable to login information are similar for the first two types of authentication: basic and NTLM authentication both involve changing configuration elements related to the server (The following section covers this topic). The third however, form-based authentication, involves changing configuration elements related to a particular form. For more information, see Link the CSV variable for form based authentication.
To link the CSV variable for basic and NTLM authentication, follow these steps:
-
Select the Design section.
-
Select the server: Choose the Virtual Users tab and select the appropriate server element in the servers tree.
-
Link the account variable to the Login configuration element:
-
In the Authorizations panel, click twice on the login column:
-
Select the picker button to access the Variable Picker dialog box.
-
Choose the
${account.col_0}expression. The first column of the "account" variable contains login values.Rather than using the Variable Picker, a faster alternative, once you have selected the login column, is to delete the value and start typing
${. NeoLoad displays a pop up listing all available variable values:Using the down and up arrow keys and the ENTER key, you can select the appropriate variable value.
In the example it is supposed that the server has been configured for Basic or NTLM authentication. If this had not been the case, you would have added, prior to linking the "account" variable, an authorization scheme by selecting the Add button and specifying a Type and a Realm/Domain.
-
-
Link the account variable to the Password configuration element: This involves the same steps as linking to the Login configuration element: Selecting the password column and changing the value to the
${account.col_1}expression.
To link the CSV variable for form-based authentication, follow these steps:
-
Select the Design section.
-
Select the HTTP request in which the login takes place: In the Virtual Users tab, choose the Virtual User, HTML page and HTTP request where the actual login and Form based authentication takes place.
For example:
-
the
recordis "VirtualUser", -
the HTTP
pageis/jpetstore/shop/signon.shtml -
and the HTTP request is
/jpetstore/shop/signon.shtml
-
-
Link the account variable to the Login configuration element: The HTTP request, in the example, defines several request parameters. In this case, the two of interest are the
usernameandpasswordrequest parameters. In your case, these request parameters are probably named differently.-
In the Definition panel, click twice on the
Valuecolumn for theusernamerequest parameter. -
Select the picker button to access the Variable Picker dialog box.
-
Choose the
${account.col_0}expression. The first column of the "account" variable contains login values. Rather than using the Variable Picker, a faster alternative, once you have selected the Value column, is to delete the value and start typing${. NeoLoad displays a pop up listing all available variable values: -
Using the down and up arrow keys and the ENTER key, you can select the appropriate variable value.
-
-
Link the account variable to the password configuration element: This involves the same steps as linking to the
usernamerequest parameter element: Selecting the Value column and, for thepasswordrequest parameter, changing the value to the${account.col_1}expression.