No keyword with name '=' found in robot

◇◆丶佛笑我妖孽 提交于 2021-02-05 07:45:29

问题


I'm writing a test case in robot framework. I'm getting the response in below json string:

{"responseTimeStamp":"1970-01-01T05:30:00",
 "statusCode":"200",
 "statusMsg":"200",
 "_object":{"id":"TS82",
            "name":"newgroup",
            "desc":"ttesteste",
            "parentGroups":[],
            "childGroups":[],
            "devices":null,
            "mos":null,
            "groupConfigRules" {
                "version":null,
                "ruleContents":null
            },
            "applications":null,"type":0
           }
}

From that I want to take "_object" using:

${reqresstr}        =       ${response['_object']}

... but am getting the error "No keyword with name '=' found" error

If I try the following:

${reqresstr}=       ${response['_object']}

... I'm getting the error "Keyword name cannot be empty." I tried removing the '=' but still get the same error.

How can I extract '_object' from that json string?


回答1:


When using the "=" for variable assignment with the space separated format you must make sure you only have a single space surrounding the "=". Your first example shows that you've got more than one space on either side of the "=". You must have only a single space on either side, or robot will think the spaces are a separator between a keyword and argument.

For the "keyword must not be empty" error, the first cell after a variable name must be a keyword. Unlike traditional programming languages, you cannot directly assign a string to a variable.

To set a variable to a string you need to use the Set Variable keyword (or one of the variations such as Set Test Variable). For example:

${reqresstr}=      Set variable  ${response['_object']}



回答2:


${reqresstr}= '${response["_object"]}'

wrap it inside quotes and two spaces after =




回答3:


There is a syntax error in your command. Make sure there is a space between ${reqresstr} and =.

Using your example above:

${reqresstr} =   ${response['_object']}


来源:https://stackoverflow.com/questions/26912861/no-keyword-with-name-found-in-robot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!