我们常接触到的接口请求类型大多是get、post,其他诸如put、delete等等都很少碰到(除非特殊业务);而在get、post中我们又更经常碰到get请求,post较为少见;今天在写自动化用例的时候刚好碰到一个post,很久没写过了一下子没想来怎么去写,于是在这里简单记录一下,方便以后学习。
最近一个月未来现金流分析
${cookie} ${Xsrf_token} sign in_uat ${systemname} ${env_type} ${host} ${username}
... ${password}
Create Session a http://168.63.65.248:8095
${headers} Evaluate {'cookie':'${cookie}','Content-Type':'application/json'}
${portid} getxls 债券风险分析 产品组合
${benchcode} getxls 债券风险分析 业绩基准
${beginDate} getxls 债券风险分析 最近一个月_开始时间
${endDate} getxls 债券风险分析 最近一个月_结束时间
${netAddress} getxls 债券风险分析 netAddress
${data} Set Variable n_port_id=${portid}&date=${endDate}
${data} To Json {"n_port_id": "${portid}", "date": "${endDate}"}
${resp} post Request a fof/api/futureFlows/findFutureFlows headers=${headers} data=${data}
Should Be True ${resp.json()['code']}==0
Should Be Equal As Strings ${resp.json()['msg']} OK
${data} Evaluate ${resp.json()}['data']
${最近一个月未来现金流分析} getxls 债券风险分析 最近一个月未来现金流分析
${最近一个月未来现金流分析} To Json ${最近一个月未来现金流分析}
Should Be True ${data}==${最近一个月未来现金流分析}
只需要学会使用to json的使用,写起来就简单得多了。