1 *** Settings *** 2 Library Collections 3 Library json 4 Library requests 5 Library RequestsLibrary 6 Library HttpLibrary.HTTP 7 8 *** Variables *** 9 &{hosts} dfc=http://dfc.xxxxx.com crm=http://crm.xxxxx.com10 11 *** Keywords ***12 新建客户13 14 登录xxxxx15 [Arguments] ${apiurl} ${jpushid} ${loginName} ${password}16 ${top} Create Dictionary Content-Type=application/x-www-form-urlencoded17 Create Session api ${apiurl} ${top}18 ${data} Create Dictionary jpushid=${jpushid} loginName=${loginName} password=${password}19 ${req} Post Request api /rest/account/login data=${data}20 log ${req.status_code}21 ${reqj} To Json ${req.content}22 log ${reqj}23 ${reqjdata} Get From Dictionary ${reqj} data24 ${TT} Get From Dictionary ${reqjdata} token25 ${store} Get From Dictionary ${reqjdata} store26 ${citycode} Get From Dictionary ${reqjdata} cityCode27 set global variable ${TT}28 Set Suite Variable ${store}29 Set Suite Variable ${citycode}30 ${form} Create Dictionary Content-Type=application/x-www-form-urlencoded31 Set Global Variable ${form}32 ${json} Create Dictionary Content-Type=application/json TT=${TT}33 Set Global Variable ${json}34 #Set Suite Variable $35 36 MoGet37 [Arguments] ${apiurl} ${type}==json ${params}==${EMPTY}38 #设置代理,用于调试39 ${proxy} set variable http://127.0.0.0:8888/40 #根据tag来获取host41 : FOR ${tag} IN @{TEST TAGS}42 \ ${host} Evaluate ${hosts}.get($tag,"")43 \ Run Keyword If "${host}"!="" Exit For Loop44 log ${host}45 #根据提交数据格式,设置Content-Type46 ${top} Run Keyword If "${type}"=="form" Create Dictionary Content-Type=application/x-www-form-urlencoded TT=${TT}47 ... ELSE Create Dictionary Content-Type=application/json TT=${TT}48 Create Session api ${host} ${top}49 ${resget} Get Request api ${apiurl} params=${params}50 Should Be Equal As Strings ${resget.status_code} 20051 log ${resget.status_code}52 ${resj} To Json ${resget.content}53 log ${resj}54 55 MoPost56 [Arguments] ${apiurl} ${type}==json ${params}==${EMPTY}57 #设置代理,抓包58 ${proxy} Set Variable http://127.0.0.1:8888/59 #根据tag来获取host60 : FOR ${tag} IN @{TEST TAGS}61 \ ${host} Evaluate ${hosts}.get($tag,"")62 \ Run Keyword If "${host}"!="" Exit For Loop63 log ${host}64 #根据提交数据格式,设置Content-Type65 ${top} Run Keyword If "${type}"=="json" Create Dictionary Content-Type=application/json TT=${TT}66 ... ELSE IF "${type}"=="form" Create Dictionary Content-Type=application/x-www-form-urlencoded TT=${TT}67 Create Session api ${host} ${top}68 ${respost} Post Request api ${apiurl} params=${params}69 Should Be Equal As Strings ${respost.status_code} 20070 ${resj} To Json ${respost.content}71 log ${resj}