Skip to content

ForEach Action

A ForEach Action loops through the values of its input variable. For each successive value, the output variable is affected and the children actions are executed. The actions below the ForEach can use the output variable in their configuration.

Note

The input variable format is special. You can define a ForEach input in two ways:

  • Create a Regex Post Processor and select "All" as the match number. In this case the ForEach children are processed for each extracted value.
  • If your input variable is named myVar, create multiple variables named:
    • myVar_1
    • myVar_2
    • myVar_3
    • and the output variable consecutively have the values of myVar_1, myVar_2 and myVar_3.

Here's an example with a regex called "categories" set to match number "All": Foreach Action

Tip

You can download a JMX of this example here and import it in your project using the JMeter project option.

To sum up:

Parameter name Description Required
Input Variable Name Name of the input variable. ${...} is omitted, e.g. write myInputVar and not ${myInputVar} No
Output Variable Name Name of the output variable. ${...} is omitted, e.g. write myOutputVar and not ${myOutputVar} Yes