Skip to main content

Testing Process Scenario

In this section, you will learn how to add flow control conditions to optimize the testing process.

Developers can now add flow control conditions (such as loops, conditional statements, waits, and grouping) within test scenarios. This enhancement caters to the utilization of more intricate test scenario/process configurations, utilizing automated testing capabilities to address the complexities of intricate scenarios.


When multiple steps in a test process are related, they can be categorized and placed into the same group. By grouping test steps, the test scene becomes more readable and operable.

Example: Categorize steps such as view details pet details, edit pet information, and view details again.

    1. Click the button "Add Step" at the bottom and select "Group".
    1. Drag the steps you want to categorize, under Grouped Steps, or add steps directly in the group.

ForEach Loop

A ForEach loop allows the repeated execution of steps based on the number of elements in a specified array, with the number of iterations matching the number of elements in the array. This loop supports extracting both the value of the current element and the index of the current iteration.

Example: There are two interfaces to get a list of pet information and to get individual pet details. Our requirement is to query the details of the pet that has just been added to the pet list, and we can use the ForEach loop to orchestrate this scenario in our automated test by following the actions below.

    1. The first step outside the loop is to request the Get Pet List interface to get the actual list data. Typically in this scenario there is an array within the interface covering basic information about multiple pets, such as pet IDs and names.
    1. Set up the ForEach loop, configuring the ForEach loop to use the array part of the response from the initial request. In this example, writing data.tags[*].id can extract all id values within tags as an array. Testing Process Scenario

    2. Inside the loop, add a request to the pet details interface, setting the request parameter ID to use the current element value from the ForEach loop. Testing Process Scenario

    3. If the list returns three pet information entries (three elements in the array), the ForEach loop will execute three times. Each execution will make an actual request with the ID value from the array returned by the initial interface. Testing Process Scenario

    4. After running the "test scenario", you can view the "test steps" in the generated test report. The details page will show that the actual request values in the ForEach loop match the response data from the initial interface, ensuring consistency in the automated testing process. Testing Process Scenario


Current Loop Element

The system automatically extracts elements from the array specified in the ForEach loop and stores them in the designated variable. At the start of each iteration, this variable is updated with the current element's value from the array. If the element is an object, you can use JSONPath to extract a specific subfield, such as {{$}}.

Current Loop Index

The index of the current loop is stored in this variable. It starts at 0 and increments by 1 at the beginning of each subsequent iteration, reflecting the current index.

In addition to being visually extracted through the Dynamic Value interaction box, the above two variables also support the use of variable expressions.

For Loop

To execute a test step repeatedly, you can set the number of loops. Additionally, in the loop's advanced settings, you can customize loop exception handling options for "Break If/On Error".

Example: A pet store owner logs into the pet inventory management console at the end of the business day, reviews the details of each of the 10 pets sold that day, and updates their status to sold.

    1. Click the button "Test Steps" at the bottom and select "For Loop".
    1. Enter the desired number of loops as 10.
    1. Drag the test step into the inner box of the condition or add the test step directly under the condition.


When there are multiple conditional judgments in the test process, you can distinguish the steps performed by the process by adding judgment conditions (If). That is, when the conditions of the judgment configuration are met, the sub-step under the judgment condition will be executed, and the sub-step will be skipped.

Example: The pet store owner determines that the pet is sold based on yesterday's sales and sets the pet's sale status to "Sold". Otherwise, query the list for sale.

    1. Click the button "Tests Step" at the bottom and select Conditional branch.
    1. In the input box behind the lf condition, fill in the variable saleStatus obtained by the request API, select the condition "Equals", and finally enter the comparison value as true. (When the sales status is judged to be true, change the pet information to "Sold")
    1. Hover over the conditional branch to stop "+ Else", click and add the "Pet List for Sale" step (otherwise, query the list of pets on sale.) )
    1. Drag the test step into the appropriate conditional branch.


When a step in the test process needs to wait for a certain period of time after execution, such as step A needs to wait for a certain amount of time before executing step B, you can solve it by adding a waiting condition.

Example: A simulated user views pet details, views for 1000ms, and then updates the browsing status in the pet details.

    1. Click the button "Tests Step" at the bottom and select "Wait".
    1. Enter the time to wait 1000 (in milliseconds).