Use parameters in scripts
You can replace some of the recorded values in your TruClient 2.0 - Web script with parameters, so that a variety of values are used for the argument during replay.
About parameters
You use parameters to make your scripts more realistic. Instead of passing the same value each time to a step argument or Evaluate JavaScript step, you create a list of values to pass. Different values are then taken from the list when the script is run in a load test. This is known as parameterizing the script.
Only some step arguments can be parameterized. For example, a boolean true/false argument cannot be replaced by parameters.
The parameter name points to a file containing a value on each row. The parameter definition defines when to start using a new value, and in what order to use the values in the list. You manage parameters and set parameter values using the VuGen interface. For details, see Parameterize scripts.
Parameters can also be used in property values of descriptors. For details, see Descriptors for scripts.
Alternatively, you can work with Virtual Table Server (VTS) to assign parameter values from a single set of values to multiple Vusers. For details, see VTS parameterization.
Convert an argument value to a parameter
You can convert the value in an argument from a literal (plain text or JavaScript code) to a parameter. You can use an existing parameter file, or create a new one.
To convert an argument value from a literal to a parameter:
- Open the Step editor for the step.
-
Select the relevant field in the step Arguments area.
- Highlight either the entire argument value or part of the argument value.
-
Right-click and select Create new parameter from selection or Replace selection with parameter.
-
If you select Replace selection with parameter, a list is displayed. Select the parameter from the list.
If you select Create new parameter from selection, enter the name of the new parameter, and click OK.
-
If the type for the argument value is Plain text, the entire value (regardless of whether you select the entire value, or part of it) is replaced with the name of the parameter you selected or created. The value type becomes Parameter automatically.
-
If the type for the argument value is JavaScript code, only the selected value is replaced with TC.getParam (“ParameterName”), and the value type remains JavaScript code.
-
Note: You must save the script in the Development window before you can see the new parameter in VuGen.
Use a parameter as an argument value
In the Step editor, for some arguments, you can select a parameter to use as an argument value.
To use a parameter as an argument value:
- Select a field in the step Arguments area.
-
Click the argument type arrow, and select the Parameter name option
.
The field value is cleared.
-
Enter the name of the parameter to use.
When running the script, the parameter’s value is evaluated as defined in the step argument.
Apply parameter values during replay
You use the VuGen interface to set when and how the values of each parameter are applied during the test. Alternatively, you can add a TC.advanceParam step in your script, to update the parameter value. For details, see TruClient 2.0 - Web functions.
See also: