Parameterize values

This topic describes how to enhance your DevWeb scripts with parameterization.

Parameterization overview

When you build your DevWeb script to emulate a business process, you create a script that contains specific values. Suppose you want to perform the script's actions (query, submit, and so forth) using different values from those recorded. To do this, you replace the values with parameters. This is known as parameterizing the script.

During the test run, DevWeb substitutes the parameter with values from a data file that you specify, in the method that you specify in the Parameter resource file (parameters.yml).

Tip: Check out the video: Tutorial #6: Using parameters

Back to top

Parameter data files

Parameter data files hold values that Vusers can access during script execution.

A parameter data file is a CSV (comma separated values) file. One file can contain values for many parameters. Each column contains the values for one parameter. The first row in the column represents the parameter name, while each subsequent row represents an additional value.

In the following example, the data file contains the "id" and "first_name" parameters:

id,first_name

120,John

121,Bill

122,Tom

Back to top

Parameter resource file (parameters.yml)

The parameters.yml file describes how to use parameters in your script. This file is stored in the script folder.

Each parameter requires its own properties, as shown in the sample below.

Tip: The parameters.yml file can use arguments defined in the runtime settings (rts.yml), by specifying the user argument key surrounded by %%. The key characters must all be lowercase. For example:

parameters:                    
  - name: myParam4 
    type: csv
    fileName: %%myfile%%
    …

Back to top

Using parameters in your script

To use parameter values during a test run, you substitute the constant values with parameters.

Parameters are exposed to the script through the load.params variable. All of the information required for the parameter, such as the location of its data file, is indicated in the parameters.yml file described above.

You can add the parameter to a string with the standard JavaScript syntax. For example:

var paramValue = load.params.myParam;
var nextParamValue = load.params.myParam; //if nextValue is "always" this will be a new value
var someString = `The value of myParam is ${load.params.myParam}`;

For details, see Parameters in the JavaScript SDK documentation.

Back to top

See also: