You can use a Variable Collection to define one or more Session Variables. You can use Session Variables to share information between Fields, Flow Templates, Response Processing Rules, Callbacks, Condition Groups and the Project. In addition, Session Variables allow the creation of customisable test configurations on a per-target basis. The Session Variables, and therefore the Variable Collection, is a key ingredient of stateful test configurations. Please note that all assets of a Project must use a single Variable Collection.
Check out the Test Configuration Details section of the documentation that includes a diagram illustrating how Variable Collections are connected to the rest of the test configuration.
Variable Collection Designer
You can create Variable Collections on the Test Assets page by clicking the Create button and selecting Variable Collection from the menu. The main areas of the Variable Collection Designer are illustrated by the picture below.
The following table describes the interface areas highlighted by the red dots.
|1||Collection Name Field||The field is an input area to provide a name for the Variable Collection. Click on the "Collection Name” text and start typing to name the Variable Collection.|
|2||Editor Menu||The menu exposes certain operations, such as saving the Variable Collection.|
|3||Variable Name Field||The field allows naming the new Session Variable.|
|4||Variable Description Field||The field allows providing an optional description for the new Session Variable.|
|5||Default Value Field||You can use this field to set a default value for the Session Variable.|
|6||Variable Type Field||The dropdown menu allows selecting the variable type. The different variable types are discussed in the next section.|
|7||Sensitive Checkbox||If a Session Variable holds sensitive information such as authentication credentials, it is highly recommended to mark it as Sensitive by checking this box. This prevents the value of the variables from being displayed on the user interface.|
|8||Add Variable Button||Once the previous fields are completed, click this button to add the new Session Variable to the collection.|
|9||Variable List||A list of registered Session Variables within the collection.|
While the different Session Variables behave identically, their purpose and how the user interface displays them are slightly different. The following table summarizes the different Session Variable types and discusses how best to use them.
|Parameter||Use a Parameter type Session Variable when it is expected or likely that users will customize its default value. When setting up the test target of a Project, the Parameter type Session Variables are displayed first under their dedicated section.|
|General||General Session Variables are best suitable to allow customization of the default field values, but it is likely that most users will find the default values sufficient.|
|Hidden||The best use of Hidden Session Variables is to hold data used internally by the different test assets without concerning the user with the variable's presence. Hidden variables are not displayed when configuring the test target(s) of a Project.|
Using Variable Collections
You can find examples on how to use Variable Collections and Session Variables via the SDK/API on GitLab.