一、作get请求以前先安装 Request库,参考github上连接 :https://github.com/bulkan/robotframework-requests/#readmehtml
二、请求&响应使用moco来模拟服务器,可参考此篇文档:Moco模拟服务器post&get请求 (二)git
三、get 请求流程以下:github
a.建立session服务器连接json
b.get请求把url和数据传入api
c.判断响应状态码是否为200服务器
d.将响应的格式转换为json格式session
e.将json设置为参数 字典的格式post
f.判断断言是否为success & 200lua
四、可在pycharm上编辑,以下:url
*** Settings ***
Library RequestsLibrary
Library Collections
*** Test Case ***
testget
${payload} Create Dictionary eid=1
Create Session event http://127.0.0.1:8899/api
${r}= Get Request event /get_event_list params=${payload}
Should Be Equal As Strings ${r.status_code} 200
log ${r.json()}
${dict} Set variable ${r.json()}
#断言结果
${msg} Get From Dictionary ${dict} msg
Should Be Equal ${msg} success
${sta} Get From Dictionary ${dict} status
${status} Evaluate str(200)
Should Be Equal ${sta} ${status}
五、运行结果以下:
六、运行结果report.html 以下: