"Run Keywords" with arguments supplied from list variable, containing AND separator

1,932 views
Skip to first unread message

Roman Fominych

unread,
Oct 22, 2014, 5:36:32 AM10/22/14
to robotframe...@googlegroups.com
following code runs as expected, two keywords are separated by "AND" separator

Running:
Run Keywords    kw1    par1=text1    AND    kw2    par2=text2

Results in:

KEYWORD: BuiltIn.Run Keywords kw1, par1=text1, AND, kw2, par2=text2
KEYWORD: kw2 par2=text2
KEYWORD: kw1 par1=text1




But if keywords are loaded to variable, then separator is not recognized, and all list items are run one by one

Running:
${list}=    Create List    kw1    par1=text1    AND    kw2    par2=text2
Run Keywords    @{list}

Results in:
KEYWORD: ${list} = BuiltIn.Create List kw1, par1=text1, AND, kw2, par2=text2
KEYWORD: BuiltIn.Run Keywords @{list}
KEYWORD: kw1
FAIL Keyword 'kw1' expected 1 argument, got 0.



how to overcome this?

Pekka Klärck

unread,
Oct 22, 2014, 8:36:04 AM10/22/14
to r.fom...@gmail.com, robotframework-users
2014-10-22 12:36 GMT+03:00 Roman Fominych <r.fom...@gmail.com>:
> following code runs as expected, two keywords are separated by "AND"
> separator
>
[snip]
>
> But if keywords are loaded to variable, then separator is not recognized,
> and all list items are run one by one

This is by design. The reason is that you cannot always control what
values your variables contain, and thus you cannot realistically be
expected to escape AND with Run Keywords or ELSE/ELSE IF with Run
Keyword If. Notice that all this Run Keyword variants are special
because they resolve variables themselves, typically variables are
replace already by Robot before keywords are called. The motivation
for that behavior is to allow e.g. Run Keyword If to contain
non-existing variables in arguments when the given expression is not
true.

There is no easy way to support AND coming from a variable with Run
Keywords. Probably the easiest solution is writing your own keyword
that handles it. It would get all arguments so that variables are
already replaced, and could then, for example, call
BuiltIn().run_keywords internally.

Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org
Reply all
Reply to author
Forward
0 new messages