+

Search Tips   |   Advanced Search


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.

  1. Select Variables in the Edit menu.
  2. Open the Variable Creation dialog box: Click on the New variable button in the Variable Edition dialog box.
  3. Select the type of variable to create: Choose the File type.
  4. Enter a name for the variable:

    • Use a meaningful name for the variable. In the example we 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 the account variable 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.
  5. Check the column separator: You can specify a column separator other than the default ";" character.
  6. 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.
  7. Define when a new value will be used: In this case, we may want a new value to be used each time a Virtual User logs in so you select the For each Virtual User option.
  8. 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 Edition dialog 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 we may have defined the accounts variable: we 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, we would change the expression to ${account.col_1}.

At this stage, the "account" variable is ready to be used and tested.


Home