【发布时间】:2015-10-20 08:35:00
【问题描述】:
现在我需要编写一个关于以下内容的脚本:
${result} set variable {}
create session url http://xxx
${resp} get request url /
should be equal as strings ${resp.status_code} 200
Dictionary Should Contain Value ${resp.jsonp(${result})} Success
log ${resp.jsonp(${result})}
但是 URL 是用 jSonp 脚本编写的。 那么机器人框架如何与 jSonp 和 jSon 脚本一起使用? 它的错误是这样的:
Invalid variable name `${resp.jsonp({})}`.
都是这些: enter image description here
jsonp来自url。url用jsonp脚本写。我需要使用 RobotFramework 获取 url 接口脚本。可能是我的脚本错误。
【问题讨论】:
-
请花点时间确保您的问题经过深思熟虑并且格式正确。我重读了好几遍,相对一无所知。根据您输入的内容,您是否在使用请求库?如果您正在使用 JSON,我建议您使用 http 库
-
yes.all the using are:*** Settings *** Library Selenium2Library Library HttpLibrary Library RequestsLibrary Library Collections
-
如果玩json,github有这样的测试:github.com/bulkan/robotframework-requests。但我不知道 JSONP 的脚本。我们的程序员使用 JSONP 脚本编写接口。
-
如果您像我在下面的回答中提到的那样使用 .content 会发生什么?恐怕我不熟悉尝试使用 JSONP,但我希望你能从我的建议中找到你需要的东西。问题是你刚刚编造了 ${resp.jsonp} 这不存在并且你没有创建它。
-
还是谢谢。也许我需要改变获取界面的方式。
标签: robotframework