The “continue for loop” statement is used in a loop, such as a for loop, to skip the current iteration and move on to the next one. When the “continue for loop” statement is encountered, the current iteration is skipped and the loop moves on to the next iteration, bypassing any remaining statements in the current iteration. This can be useful for skipping specific iterations or for controlling the flow of the loop based on certain conditions. The “continue for loop” statement should be placed within the loop’s body, and its use can greatly simplify the loop’s code by allowing certain iterations to be skipped based on specific conditions.
***settings***
Documentation Skips the current FOR loop iteration and continues from the next
*** Variables ***
*** Keywords ***
*** Test Cases ***
continue for loop
${list} = Create List 10 20 30
FOR ${I} IN @{list}
IF ${I} == ${20}
log to console ${i}
log to console Going for next iteration
continue for loop
log to console after continue for loop, this statement will not execute
END
END
tech-bloggers@tech-bloggers:~/robot_example$ robot continue_for_loop.robot
==============================================================================
Continue For Loop :: Skips the current FOR loop iteration and continues fro...
==============================================================================
continue for loop .20
Going for next iteration
continue for loop | PASS |
------------------------------------------------------------------------------
Continue For Loop :: Skips the current FOR loop iteration and cont... | PASS |
1 test, 1 passed, 0 failed
==============================================================================
Output: /home/tech-bloggers/robot_example/output.xml
Log: /home/tech-bloggers/robot_example/log.html
Report: /home/tech-bloggers/robot_example/report.html