Reputation: 87
I'm trying to use combination Run Keywords and Create Dictionary built-in keywords This code:
Run Keywords
... &{dict} Create Dictionary ${data}
returns:
Variable '&{dict}' not found.
any ideas?
message
Upvotes: 0
Views: 539
Reputation: 2813
Run Keyword
specifically designed to be used in setup or tear down methods where creating an user defined keyword is an Overkill. User defined keyword does the same thing as Run Keywords but additionally it can return you the values from the enclosing keywords.
Here is the Run Keywords
documentation
Coming to the problem. Run keyword
will treat any variable argument as keyword unless it is not the parameter of the keyword using AND
operator. In the error - &{dict}
it is searching for the variable but it is not found. hence the error. Following code demonstrate the behavior of Run keywords
***Variable
${keyword}= comment something
***Testcase
Test1
Run Keywords ${keyword}
***Keyword
comment something
log This is comment
Output -
Actual resolution -
Define new keyword and enclose the keywords of your requirement and call the user defined keyword.
***Keyword
User Defined Keyword [Arguments] ${key} ${value}
&{dict}= Create Dictionary ${key} ${value}
Return from keyword ${dict}
*** Testcase
User Keyword Demo
&{dict}= User Defined Keyword name=xyz
Log ${dict}
Output =
Upvotes: 3