Contents ▼

Dynamic Datasets

Datasets can be used to supply dynamic or unique values to your scripts, so that each v-user sends something different to the server.

For example:

  • Logging in with a different username and password each time.
  • Submitting a registration form with unique personal data for each user.
  • Searching for any of 100 search phrases at random.

For most web applications, testing with dynamic data is important because it forces the application and database to work harder than simply submitting the same data over and over. If you submit the same data over and over, it’s likely that one or more layers of your application will cache the results, leading to artificially good performance.

Editing Datasets

Editing datasets in Loadster is much like using a spreadsheet. Each row signifies a separate entry in the dataset, and you can use multiple columns to supply multiple fields related to the same row.

A dataset with data

For example, if you are providing user data where each user has a corresponding first name, last name, and email address, you can store these as columns to make certain they do not get mixed up with one another.

Importing Data

To save time, you may want to import data into your dataset from a CSV file. You can do this by first creating an empty dataset, and clicking the Import CSV… button.

Using Datasets in Scripts

Datasets must be mapped to script variables before you can use them in your scripts. Go to the script you want to use dynamic data, and click Bind Variables.

Binding datasets to dynamic script variables

Binding a Variable

The Bind Variables dialog is how you bind variables to rows from your dataset.

Even though we treat them as variables, they are actually more like cursors in a data access library, because they can possibly return a different value each time you reference them.

Example of a script variable called user that pulls from the Users dataset

Whatever variable name you enter here will be available in your script with the ${var} notation. For example, if you enter a name of user, you can use it in your script as ${user}.

Important: If your dataset has multiple columns, an entire row will be selected each time, and the variable will be an array. For example, in a two-column dataset containing usernames and passwords, the username would be in ${user[0]}, and the password in ${user[1]}.

Dataset Selection Strategies

Each time you reference the variable in your script, Loadster will pull a value from the underlying dataset. You can specify whether to pull new values sequentially or randomly.

  • sequentially - The first time a v-user reads a row from the dataset, the first row will be used, and then the second, and so on. Once the end of the dataset is reached, it starts over from the beginning.

  • randomly - Each time a random row is pulled from the dataset, regardless of what row was pulled previously.

Dataset Update Strategies

You can also control how often a new value is pulled from the dataset.

The update strategies are:

  • for each v-user - Each v-user will select a new value from the dataset. The user will keep reusing the same value, no matter how many times the variable is referenced or how many iterations of the script are run.
  • for each iteration - Each v-user will select a new value from the dataset at the beginning of each iteration. If that same v-user repeats the script, a new value will be selected for each iteration of the script.
  • for each occurrence - Every time the variable is used in a script, a new value will be obtained from the dataset. Even if the same virtual user references it 2+ times in one script iteration, a new value will be obtained each time.

Using the variable in your script

Once you have configured a dataset variable to work with your script, you can reference it in your commands with the following variable notation:

  • ${Email}
  • ${ProductID}
  • ${FirstName}

If you are using a multi-column dataset, you can specify which column to use with this zero-based array notation:

  • ${User[0]}
  • ${User[1]}
  • ${User[2]}

You can leave off the [0] to signify the first column. In other words, the following are identical:

  • ${User}
  • ${User[0]}

Where to use variables

Whenever Loadster comes across your variable, it will automatically replace it with a value from the dataset. Variables can be used almost anywhere in an HTTP step: the URL, Page Resources, Request Headers, Request Body, etc.

To learn more about variable syntax and advanced expressions, check out Variables and Expressions.

Other Ways To Set Variables

Variables are not only populated from datasets. You can also set variables during script runtime by capturing output from the site or application you are testing. To learn how to do this, check out Capturing Rules.