For Each Statement


Iterates over the elements of a list or a set.


for each item in expr statement
Variable Description
item A variable name.
expr An expression that evaluates to a list or a set.
statement A single statement or a series of statements.


The for each iterator executes once for each element in the list or set specified by expr. Each time it executes, the iterator sets item to the value of another list or set element, the statement section executes for that value, and then control passes back to the iterator to check for another item. When every element in the list or set has been processed, control passes to the next statement in the script.


[-] testcase foreachExample()
	[-] LIST OF STRING lsFruit = {...}
		[ ] "apple"
		[ ] "mango"
		[ ] "kiwi"
	[ ] STRING sFruit
	[-] for each sFruit in lsFruit
		[ ] Print(sFruit)
	[ ] // This script prints:
	[ ] // apple
	[ ] // mango
	[ ] // kiwi