Go over each element in a collection and do something with it.
If you have an array of items, or any other collection that can be traversed, and you want to perform an operation with each item, use this element.
Http Client, a Json Reader, or set manually with Set Parameter.${array_name}item.Suppose you have an array of players, imaginatively called players, and each player has a score. Here is an example showing how you could output each player's score:
${players}player. Note the lack of expression syntax wrapper! Do not write ${player} by mistake!Text Response element inside the Loop elementText Response element's Text field, write Player${player.natural}'s score is${player.value.score}
| Field | Description |
|---|---|
value |
The current value of the collection being iterated over |
index |
Current programmatic index of the loop (starts at 0) |
natural |
Human readable index (starts at 1) |
first |
Boolean flag, whether the item is first in the collection |
last |
Same as first, only checks if the item is last |