Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return results in Robot Framework keyword?

Tags:

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 
like image 652
Matilda Owusu Boateng Avatar asked Sep 28 '11 08:09

Matilda Owusu Boateng


People also ask

How do I return a value in Robot Framework keyword?

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.

How do I return two values in Robot Framework?

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.

What are keywords in Robot Framework?

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.


1 Answers

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:

  • Return from keyword
  • Return from keyword if
  • Run keyword and return
  • Run keyword and return if
  • Run keyword and return status
like image 161
Bryan Oakley Avatar answered Oct 13 '22 10:10

Bryan Oakley