Document nested for loops.
Fixes
@@ -299,8 +299,8 @@ removed altogether in Robot Framework 4.0.
Nested for loops
~~~~~~~~~~~~~~~~
-Having nested for loops is not supported directly, but it is possible to use
-a user keyword inside a for loop and have another for loop there.
+Starting from Robot Framework 4.0, it is possible to use nested for loops
+simply by adding another loop inside a loop:
.. sourcecode:: robotframework
@@ -308,14 +308,30 @@ a user keyword inside a for loop and have another for loop there.
Handle Table
[Arguments] @{table}
FOR ${row} IN @{table}
- Handle Row @{row}
- END
-
- Handle Row
- [Arguments] @{row}
FOR ${cell} IN @{row}
Handle Cell ${cell}
END
+ END
+
+There can be multiple nesting levels and one loop can contain several loops:
+
+.. sourcecode:: robotframework
+
+ *** Test Cases ***
+ Example
+ FOR ${root} IN r1 r2
+ FOR ${child} IN c1 c2 c3
+ FOR ${grandchild} IN g1 g2
+ Log Many ${root} ${child} ${grandchild}
+ END
+ END
+ FOR ${sibling} IN s1 s2 s3
+ Log Many ${root} ${sibling}
+ END
+ END
+
+With earlier Robot Framework versions nesting for loops was not supported directly,
+but it was possible to have a user keyword inside a loop and have another loop there.
Using several loop variables
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
