Action - Create Variable
A create variable action anywhere in the scenario will create a global variable that is accessibly from code and if statements.
- Multiple variables with the same name will cause a compile error.
- The Value property, only defines the initial value of the variable (this is assigned before the test begins).
- To change the value of a variable, use script to access it using the name of the action.
- A preview of the variable declaration code is displayed below the properties in the scenario builder.
The location and scope of a variable doesn't matter as they are created for the entire scenario and before the test is run.
i.e. A script action that is run earlier in the scenario can access any create variable action later in the scenario.
A script action that is outside of a loop /if statement can also access variables declared inside of a loop / if statement.
- Name: Used to identify the variable, must be unique.
- Action Type: Always returns ActionType.Script (enum)
- Type: The type of the defined variable.
- While any type usable from script can be defined as the type of the variable, its recommended that primitive types be used.
- Is Static: Defines if the variable is a static variable.
- Each variables scope is a single virtual instance of the scenario.
- To declare a variable usable across multiple virtual runs of the scenario, set the 'static' property to true.
- Value: the initial value of the variable.
- The initial value of the variable is used as entered (i.e. if the type of the variable is a string, quote marks are required, etc).
- If the initial value is empty, the variable is not initialized.