How to run [FOR LOOP] in [Run Keyword If]

3,471 views
Skip to first unread message

Wentao Wu

unread,
Jul 25, 2017, 6:33:21 AM7/25/17
to robotframework-users
Hi All

Robot can support this format:

:FOR     ${var}      IN     @{values}
\\      Run Keyword IF     '${var' == 'EXIT' .     EXIT For Loop
\\      Do Something         ${var}

But how to support add [FOR LOOP] in [Run Keyword If] :


Run Keyword IF    "${var_list}"  is not "${None}"       :FOR     ${var} .   IN .   ${var_list}
...                                                                                     \\      Do Something         ${var}
ELSE                    Do Something

Thanks!


Ibraheem Saleh

unread,
Jul 25, 2017, 10:12:45 AM7/25/17
to wuwent...@gmail.com, robotframework-users
You have to put the for loop in a keyword and then have Run Keyword If call that keyword.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Wentao Wu

unread,
Jul 26, 2017, 3:38:39 AM7/26/17
to robotframework-users, wuwent...@gmail.com
Thanks very much for your reply, seems robot can't support add for loop after run keyword if ?
as I don't want to add more keywords, it's really a very simple line.

Why I need this feature?
1. I'm writing more keywords, the input keyword argument will have  empty vaule/list value
2. in my keyword content,I will do check ,if the value is not None, then do for loop to use the list value in ${var}

We have too many this keywords, if we need to write 20 keyword in this format, we will add 40 keywords to do it? it's not a good solution for us.

Thanks!


 
You have to put the for loop in a keyword and then have Run Keyword If call that keyword.
On Tue, Jul 25, 2017 at 2:56 AM, Wentao Wu <wuwent...@gmail.com> wrote:
Hi All

Robot can support this format:

:FOR     ${var}      IN     @{values}
\\      Run Keyword IF     '${var' == 'EXIT' .     EXIT For Loop
\\      Do Something         ${var}

But how to support add [FOR LOOP] in [Run Keyword If] :


Run Keyword IF    "${var_list}"  is not "${None}"       :FOR     ${var} .   IN .   ${var_list}
...                                                                                     \\      Do Something         ${var}
ELSE                    Do Something

Thanks!


--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.

Tatu Aalto

unread,
Jul 29, 2017, 8:16:57 AM7/29/17
to wuwent...@gmail.com, robotframework-users
Ugh

The feature you are looking doesn't exist in Robot Framework. If you want to have a for loop after if statement, in Robot Framework test data, only option is to put that for loop inside of a keyword. Just like was said in the previous response. 

The other option is to hide such complex logic in a library keyword, which will bring the full power of programming language for you to use. Using, example Python, will bring many benefits: creating complicated logic is easier, more readable, easier to maintain and you can have other logical operations that what is provided by the Robot Framework.

I tend to favour hiding complex logic in a library keyword. For me, it's easier to write and test.

-Tatu
Send from my mobile

On Jul 26, 2017 10:38, "Wentao Wu" <wuwent...@gmail.com> wrote:
Thanks very much for your reply, seems robot can't support add for loop after run keyword if ?
as I don't want to add more keywords, it's really a very simple line.

Why I need this feature?
1. I'm writing more keywords, the input keyword argument will have  empty vaule/list value
2. in my keyword content,I will do check ,if the value is not None, then do for loop to use the list value in ${var}

We have too many this keywords, if we need to write 20 keyword in this format, we will add 40 keywords to do it? it's not a good solution for us.

Thanks!

You have to put the for loop in a keyword and then have Run Keyword If call that keyword.
On Tue, Jul 25, 2017 at 2:56 AM, Wentao Wu <wuwent...@gmail.com> wrote:
Hi All

Robot can support this format:

:FOR     ${var}      IN     @{values}
\\      Run Keyword IF     '${var' == 'EXIT' .     EXIT For Loop
\\      Do Something         ${var}

But how to support add [FOR LOOP] in [Run Keyword If] :


Run Keyword IF    "${var_list}"  is not "${None}"       :FOR     ${var} .   IN .   ${var_list}
...                                                                                     \\      Do Something         ${var}
ELSE                    Do Something

Thanks!


--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsubscrib...@googlegroups.com.

To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages