本文介绍了找不到名称为"$ {body} = Create Dictionary"的关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

*** settings ***

Library  RequestsLibrary
Library  Collections
Library  OperatingSystem
Library  SeleniumLibrary

*** Variables ***

${username}     XXXXXX

${password}     YYYYYY

${locale}       ZZZZ


*** test cases ***

TC1

            ${body}= Create Dictionary  username=       ${username}  password=      ${password}
            ${header}= Create Dictionary   Accept=application/json, text/plain, */*    Content-Type=application/json, Accept-Language=${locale},
            Create Session OA2  ${base_url}
            ${response}= post request   OA2 /oauth/v2/token   data=     ${body}    headers=     ${header}
            log to console  ${response.status_code}
            log to console  ${response.content}

推荐答案

您必须遵循以空格分隔的格式.

在下面的代码行(以及其他代码行)中,您似乎只在变量和关键字之间使用1个空格 $ {body} =创建字典.
这就是机器人无法正确解析代码并引发错误的原因.扩展该代码以使用至少2个空格.
您应该尝试这样的代码.
$ {body} =创建字典用户名= $ {username}密码= $ {password}

In following code line (and others) you seem to only use 1 space between variable and keyword ${body}= Create Dictionary.
That's why robot can not parse the code correctly and the error is raised.
Expand that code to use at least 2 space separation.
You should try the code like this.
${body}= Create Dictionary username=${username} password=${password}

当然还要相应地修改其余代码.

And of course revise rest of the code accordingly.

我还建议您阅读用户指南.
它包含许多有用的信息.

I also recommend you study the user guide.
It contains a lot of useful information.

这篇关于找不到名称为"$ {body} = Create Dictionary"的关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 17:19