Is there a possibility to return two variables in Robot Framework?
${result1}, ${result2}= MyKeyword
doesn't work.
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).
No, you can not have two returns in a function, the first return will exit the function you will need to create an object.
You cannot explicitly return two variables from a single function, but there are various ways you could concatenate the two variables in order to return them.
The short version is: set a variable in your keyword, and use the [return] testcase setting to return that variable. Robot also provides several keywords to explicitly return a value from anywhere in a keyword: Return from keyword. Return from keyword if.
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}
Remove the ,
${result1} ${result2} = MyKeyword
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With