Skip to main content

Parameterizing Virtual User Scripts

Parameterization allows you to change virtual user behaviour by taking values from data sources. Data source files can contain multiple values, and the way those values are accessed by VUs is fully customizable. The data within data sources is accessed by virtual users (VUs) via the VU methods available within the various Data Dictionary APIs.

note

No matter what type of data source is being accessed, the method calls are exactly the same.

Example Parameterization Code

The following code examples demonstrate how strings (text) can be retrieved from a data source. All of these examples work whatever the data source type.

C# Examples:

// original recorded values in a Web Virtual User Script
form_52_0_1.GetInputElement("fullName").Value = "Martin Petrov";
form_52_0_1.GetInputElement("password").Value = "p@ssw0rd1";
form_52_0_1.GetInputElement("username").Value = "Martin";

// parameterized values
form_52_0_1.GetInputElement("fullName").Value = GetString("custForename") + " " + GetString("custSurname");
form_52_0_1.GetInputElement("password").Value = GetString("custPassword");
form_52_0_1.GetInputElement("username").Value = GetString("custForename");

Java Examples:

// original recorded values in a Web Virtual User Script
form_52_0_1.getInputElement("fullName").setValue("Martin Petrov");
form_52_0_1.getInputElement("password").setValue("p@ssw0rd1");
form_52_0_1.getInputElement("username").setValue("Martin");

// parameterized values
form_52_0_1.getInputElement("fullName").setValue(getString("custForename") + " " + getString("custSurname"));
form_52_0_1.getInputElement("password").setValue(getString("custPassword"));
form_52_0_1.getInputElement("username").setValue(getString("custForename"));