You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
New BuiltIn keyword for continuing for loop execution #1125
Originally submitted to Google Code by SamerAdra on 7 May 2012
I would like to be able to continue to the next iteration in a for loop... That is, skip all the rest of the stuff in the current block and start with the next variable in the loop. It would make certain operations a lot easier.
The existing "Exit For Loop" is the same as "break" in C#.
"Continue For Loop" would be the same as "continue" in C#.
We have decided not to implement this keyword because you can already use Run Keyword If to simulate it:
:FOR ${x} IN @{STUFF}
\ Do something ${x}
\ Run Keyword If "${x}" == "zzz" Go to bed
Adding separate keyword wouldn't help too much either because you needed to use it with Run Keyword If anyway. I actually think the example above is simpler than the example demonstrating Continue For Loop below:
:FOR ${x} IN @{STUFF}
\ Do something ${x}
\ Run Keyword If "${x}" != "zzz" Continue For Loop
\ Go to bed
Notice that Exit For Loop was different because simulating break required a really ugly hack ( issue 502 ).
Originally submitted to Google Code by SamerAdra on 7 May 2012
The trouble comes when you want to do a lot of stuff in a for loop, which won't all fit in a single keyword.
What if there are 10 keywords in my for loop and I only want to run them based on some condition? Under the current implementation, I would have to use multiple redundant "Run Keyword If" statements, one for each keyword in the for loop that I didn't want to execute. (Another option would be to abstract out the rest of the for loop body into it own keyword, but that might not always make sense.)
Needs to be refactored after we decide, if we are going to deprecate exceptions with attributes ROBOT_XX_YY in favor of different types of exceptions. Right now, it really doesen't make sense to throw ExecutionFailed with attributes denoting that it didn't after all
Activity
spooning commentedon Jun 29, 2014
We have decided not to implement this keyword because you can already use
Run Keyword Ifto simulate it::FOR ${x} IN @{STUFF}
\ Do something ${x}
\ Run Keyword If "${x}" == "zzz" Go to bed
Adding separate keyword wouldn't help too much either because you needed to use it with
Run Keyword Ifanyway. I actually think the example above is simpler than the example demonstratingContinue For Loopbelow::FOR ${x} IN @{STUFF}
\ Do something ${x}
\ Run Keyword If "${x}" != "zzz" Continue For Loop
\ Go to bed
Notice that
Exit For Loopwas different because simulating break required a really ugly hack ( issue 502 ).spooning commentedon Jun 29, 2014
The trouble comes when you want to do a lot of stuff in a for loop, which won't all fit in a single keyword.
What if there are 10 keywords in my for loop and I only want to run them based on some condition? Under the current implementation, I would have to use multiple redundant "Run Keyword If" statements, one for each keyword in the for loop that I didn't want to execute. (Another option would be to abstract out the rest of the for loop body into it own keyword, but that might not always make sense.)
-Samer
spooning commentedon Jun 29, 2014
This would be a good function for us too. (Common function at programming languages)
That creates ones more a new keyword for a simple task.
spooning commentedon Jun 29, 2014
The has recently been interest in providing a patch to implement this feature. Let's see will that happen even before 2.7.7.
spooning commentedon Jun 29, 2014
This has been asked inside NSN, so we try to get this to 2.8 or at least 2.8.1 or so.
spooning commentedon Jun 29, 2014
It would be also convenient to offer users "Continue For Loop If"-keyword so that
Run Keyword If ${condition} Continue
can be replaced with
Continue If ${condition}
spooning commentedon Jun 29, 2014
a colleague of mine already implemented 'Continue For Loop' in below repository:
https://code.google.com/r/scathaig-robotframework/source/browse
spooning commentedon Jun 29, 2014
Thanks for contributing, we were already looking into this.
spooning commentedon Jun 29, 2014
This issue was updated by revision 86a1236658ba.
Implementation done. Could be refactored. Documentation not done.
spooning commentedon Jun 29, 2014
This issue was updated by revision 9fa46cd352a2.
Added Continue For Loop to user guide
spooning commentedon Jun 29, 2014
Needs to be refactored after we decide, if we are going to deprecate exceptions with attributes ROBOT_XX_YY in favor of different types of exceptions. Right now, it really doesen't make sense to throw ExecutionFailed with attributes denoting that it didn't after all
spooning commentedon Jun 29, 2014
This issue was updated by revision 0403877e7140.
Fixed typos in user guide
spooning commentedon Jun 29, 2014
This issue was updated by revision b5ff0515391c.
Updated documentation
spooning commentedon Jun 29, 2014
This issue was updated by revision 8776a8a05cbb.
Added regression tag to continue for loop tests
spooning commentedon Jun 29, 2014
This issue was updated by revision c97d732a85f5.
Continue For Loop now uses its own exception instead of custom
exception with the attribute ROBOT_CONTINUE_FOR_LOOP.
This attribute was also removed. Also removed the related tests
and helpers.
spooning commentedon Jun 29, 2014
This issue was updated by revision 8d8e447a63bd.
Removed rest of the refences related to the old Continue For Loop implentation.
spooning commentedon Jun 29, 2014
This issue was updated by revision 53f441c29d43.
Enhanced docs in UG.
spooning commentedon Jun 29, 2014
This issue was updated by revision 0df0d354dbbc.
Enhanced kw docs. Next reviewing code and tests.
spooning commentedon Jun 29, 2014
This issue was updated by revision 859997b3d04f.
spooning commentedon Jun 29, 2014
This issue was updated by revision 4eb3f63b01ad.
Status was always PASS if ExecutionFailed was raised with an empty message.
spooning commentedon Jun 29, 2014
This issue was updated by revision 09b4d9c80d0f.
Added Continue For Loop keyword logging.
spooning commentedon Jun 29, 2014
Reviewed and considered done.
spooning commentedon Jun 29, 2014
Yes, this was done....
spooning commentedon Jun 29, 2014
This issue was updated by revision 0c041d0a0ef7.
If used in keyword's teardown, the for loop was passed. This is now fixed with tests.