RobotFrameWork DEMO
*** Settings ***
Library RequestsLibrary
Library json
Library Collections
Library requests
*** Test Cases ***
生成二维码图片
#设置代理
#&{proxy}= Create Dictionary http=http://172.17.10.122:8888
#自定义请求头
${dict}= Create Dictionary content-type=application/x-www-form-urlencoded
#创建一个Session
Create Session _session URL ${dict}
#定义输入的变量
${params}= Create Dictionary salespersonId=Nn4QNs7Ulk shopCode=00102063 carId=M18KhaUHJq productId=1030
#发送post请求
${response}= Post Request _session /alipay/v1/alipayqrcodeapi/getAlipayQRCodeDetail.json ${params}
#校验请求是否成功
Should Be Equal As Strings ${response.status_code} 200
#转化返回结果为json格式
${json}= Set Variable ${response.json()}
#校验请求结果
Should Be True ${json["success"]}
#打印日志
Log ${json["success"]}
*** Keywords ***
qrCodeUrl
[Arguments] $[salespersonId] $[shopCode] $[carId] $[productId]
${dict}= Create Dictionary content-type=application/x-www-form-urlencoded
Create Session session URL ${dict}
@{carilist} Create list carId=$[carId] productId=$[productId]
${data}= Create Dictionary car=${carlist} salespersonId=$[salespersonId] shopCode=$[shopCode]
${res}= Post Request session /alipay/v1/alipayqrcodeapi/getAlipayQRCodeDetail.json ${data}
Should Be Equal As Strings ${res.status_code} 200
${json}= Set Variable ${res.json()}
Set Suite Variable ${qrCodeUrl} ${res["qrCodeUrl"]}
[Arguments] $[salespersonId] $[shopCode] $[carId] $[productId]
${dict}= Create Dictionary content-type=application/x-www-form-urlencoded
Create Session session URL ${dict}
@{carlist} Create list carId=$[carId] productId=$[productId] salespersonId=$[salespersonId] shopCode=$[shopCode]
${res}= Post Request session /alipay/v1/alipayqrcodeapi/getAlipayQRCodeDetail.json ${data}
Should Be Equal As Strings ${res.status_code} 200
${json}= Set Variable ${res.json()}
Set Suite Variable ${qrCodeUrl} ${res["qrCodeUrl"]}

浙公网安备 33010602011771号