Contents ▼

Dynamic Datasets

Dynamic Datasets can be used to supply unique values to your scripts, so that each virtual 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.

Editing Datasets

Editing datasets in Loadster is pretty 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 simulating users with 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.

Importing a CSV into a dataset

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 Dataset Variable.

Binding a dataset to a script variable

Binding a Variable

A new row will appear at the top of your script.

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 select 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]}.

Variable Selection Strategies

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

Dataset variable selection strategies

Selecting a value sequentially means that the first time you read a new value 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.

Selecting a value randomly means that each time a random value is selected, without regard to the previous selection.

Variable Update Strategies

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

Dataset variable update strategies

The update strategies are:

  • Update value 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.
  • Update value 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.
  • Update value 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 command, including the URL, Page Resources, Request Headers, and Request Body.

Using a variable in a script

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.