Return two values in Robot Framework
17,701
Solution 1
Yes, just place the variables in separate cells, both when assigning and when returning the values.
For example:
*** Test Case ***
Example
${value1} ${value2} return two values
Should be equal ${value1} this is value 1
Should be equal ${value2} this is value 2
*** Keywords ***
Return two values
${v1}= set variable this is value 1
${v2}= set variable this is value 2
[Return] ${v1} ${v2}
Solution 2
Remove the ,
${result1} ${result2} = MyKeyword
Solution 3
${result1} ${result2} = MyKeyword
worked for me.
${result1} ${result2} = MyKeyword
gave me:
No keyword with name '=' found.
In case it matters, I'm using spaces only, no tabs.
Author by
kame
I live in the area between Basel and Zürich. Nice to meet you. :)
Updated on July 22, 2022Comments
-
kame almost 2 years
Is there a possibility to return two variables in Robot Framework?
${result1}, ${result2}= MyKeyword
doesn't work.
-
kame almost 8 yearsThis doesn't work for me. '${result1} ${result2}=' --> keyword not found
-
shicky almost 8 yearsGuessing this was an issue with separation or you weren't actually returning two values from the keyword
-
kame almost 8 yearsAnd also an issue with the equals sign.
-
shicky almost 8 yearsyes this is the separation issue, it's because you have the equals sign on the variable. If it were separated appropriately it should work fine unless I'm mistaken
-
logicalscope almost 7 yearsI realize it is a year since this post, but the answer here is mildly syntactically incorrect. There cannot be more than 1 space between the '=' and the variable to its left (zero spaces are fine as well). Any more spaces results in Robot treating the equal sign as a distinct keyword (which will fail). Unfortunately, since SO thinks the edit is too trivial, I can't remove those spaces.
-
shicky almost 7 years@logicalscope I'm afraid I disagree, I used the above method many times without it failing. My previous workplace used 4spaces as separation and it worked without issue