Return results in Robot Framework keyword?

前端 未结 5 1412
青春惊慌失措
青春惊慌失措 2021-02-05 08:34

How can I return the results after running a keyword?

Example:

mykey word [Arguments] input
   ${results}=  getme input

But I want to u

5条回答
  •  臣服心动
    2021-02-05 09:13

    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

提交回复
热议问题