How to set the value of a dictionary element for a keyword result in Robot Framework?

I know that I can access one element from a dictionary object with this format $ {dict ['KEY']}. Like this:

|   | Log | ${dict['KEY']} |

And I can set the plain old scalar as follows:

|   | ${scalar}= | RFKeyword | "Yowp"

But if I try to establish a dictionary element like this

|   | ${dict['KEY']}= | RFKeyword | "Yowp"

I get "RFKeyword", "Yowp" in a variable, and not the result of what RFKeyword generates when processing "Yowp", as I do with this

|   | ${scalar}= | RFKeyword | "Yowp"

Help please

+5
source share
2 answers

As you probably understood, you cannot assign a dictionary from a keyword. You need to very accurately follow the dictionary syntax. you can only return variables to lists or scalars.

, . , , .

, Google " " . :

Create dictionary | ${my_dict} | a | b

:

set to dictionary | ${my_dict} | c | d

:

${my_dict["a"]}

, :

${my_dict.get('non-key','default value')}
+6

, . , , , , :

${scalar}= | RFKeyword | "Yowp"
Set To Dictionary  | ${dict}  |  KEY    | ${scalar}
+3

All Articles