How can I return the results after running a keyword?
Example:
mykey word [Arguments] input ${results}= getme input
But I want to use these results:
${results} = mykey word newinput
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.
Yes, just place the variables in separate cells, both when assigning and when returning the values. Show activity on this post. And also an issue with the equals sign.
Keywords are the foundation upon which all robot tests are built. There are generic keywords provided by robot, and there are special-purpose keywords that you can create yourself.
The Robot Framework user's guide describes how to return a value from a keyword. See User keyword return values.
The short version is: set a variable in your keyword, and use the [return]
testcase setting to return that variable.
Here's an example:
*** Keywords *** mykey word [Arguments] ${input} ${string}= set variable the string is "${input}" [return] ${string} *** Test Cases *** Call custom keyword and get result ${results}= mykey word newinput Should be equal ${results} the string is "newinput"
Robot also provides several keywords to explicitly return a value from anywhere in a keyword:
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