what is a variable code example
Example 1: what is a variable?
count = 0;
While true
{
count = count + 1;
print(count);
}
count = 0
While True:
count = count + 1
print(count)
1
2
3
4
5
6
7
8
9
...
Example 2: how to define variables
-Use pm.globals to define a global variable:
pm.globals.set("variable_key", "variable_value");
-Use pm.collectionVariables to
define a collection variable:
pm.collectionVariables.set("variable_key", "variable_value");
-Use pm.environment to define an environment
variable (in the currently selected environment):
pm.environment.set("variable_key", "variable_value");
-You can use unset to remove a variable:
pm.environment.unset("variable_key");
-Defining local variables
Local variables are temporary values you set
in your request scripts using the following syntax:
pm.variables.set("variable_key", "variable_value");
Example 3: how to use a variable
You do things!