如何将字典添加到机器人框架中的列表中

How to add a dictionary to a list in robot framework

假设我有一个列表:

contacts: []

现在,我想通过 Robot Framework 关键字向该列表添加字典。这个字典的Keyemail_address,它的值作为参数传递。这是关键词:

Test keyword
[Arguments]      ${email}      #test@test.com
Append to list   ${contacts}   {"email_address":"$email"}

但这行不通。我希望最终结果是这样的:

contacts: [{"email_address":"test@test.com"}]

我该怎么做?

您必须先创建字典:

Test keyword
    [Arguments]      ${email}      #test@test.com
    &{dictionary}=    Create Dictionary    email_address=${email}
    Append to list   ${contacts}   ${dictionary}