Loop
Supports multiple loop types, including iterating a specified number of times, exiting a loop when a condition is met, and looping through test data. When handling test data loops, the tool allows the use of custom uploaded CSV files, results from previous steps, variables, and fixed values.
How to Add a Loop Controller
Add Loop Controller
Add steps and select the loop controller.
Set Loop Conditions
Set loop conditions in the drawer.
- Complete traversal of all test data: Ensure test data is set. The loop will exit once all test data has been processed.
- Loop by iteration count: Execute the loop for a set number of iterations and then exit.
- Conditional exit: Set a condition for the loop, and it will exit once the condition is met.
Loop interval: The interval time between each loop.
Timeout: Define a timeout period after which the loop will exit. The default value is 0, meaning no timeout is set. Setting a timeout helps prevent infinite loops.
Set Loop Test Data
To use test data in the loop, toggle the switch and configure the test data. Refer to the scenarios below for practical examples.
Variables and Fixed Values
❗️❗️❗️ Variables/Fixed values must be in array format ❗️❗️❗️
Loop element content: Use the fixed variable name {{$item}}
.
Loop index: Use the fixed variable name {{$key}}
, with the key value starting from 0.
Example:
If the array element is an object and you need to use the email field, use {{email}} directly as the input parameter.
[
{
"email": "test01@email.com",
"password": "123456"
},
{
"email": "test02@email.com",
"password": "123456"
},
{
"email": "test10@email.com",
"password": "7777777"
}
]
For non-object array items, use {{$item}} as the input parameter directly in the interface.
[1, 2, "John", "David", "Kelly"]
Return Results from Previous Steps
❗️❗️❗️ Supports looping array format data ❗️❗️❗️
Loop element content: Use the fixed variable name {{$item}}
.
Loop index: Use the fixed variable name {{$key}}
, with the key value starting from 0.
Note: If the returned data from the interface is an object, please refer to the usage method outlined below.
The result returned by the interface is an object
{
"data": {
"errcode": 0,
"errstr": "success",
"list": [
{
"email": "test01@email.com",
"password": "123456"
},
{
"email": "test02@email.com",
"password": "123456"
},
{
"email": "test10@email.com",
"password": "7777777"
}
]
}
}
Extract the array data using the JsonPath expression $.data.list, as shown below:
[
{
"email": "test01@email.com",
"password": "123456"
},
{
"email": "test02@email.com",
"password": "123456"
},
{
"email": "test10@email.com",
"password": "7777777"
}
]
If you need to use the email field data, you can directly use {{email}}
as the input parameter in the interface.
Test Data
Begin by uploading a test data file. For detailed upload instructions, please refer to the provided documentation.
Once you've selected the test data, you can preview it on the right-hand side.
Example:
To loop through the phone column data, input {{phone}} as the parameter value in the interface. To loop through the index, use the variable name {{$key}}.