*** Settings *** Suite Setup Library RequestsLibrary Library Collections Library urllib3 Library DatabaseLibrary *** Variables *** ${header} {'content-type':'application/json','X-APP-ID':'470236309865238528'} ${url} http://api-client-ztb.qniao.cn *** Test Cases *** Get_verification-code #获取验证码 Disable Warnings ${headers} Create Dictionary content-type=application/json X-APP-ID=470236309865238528 Create Session ZTBT https://api-client-uec.qniao.cn ${headers} ${value} Set Variable {"verifiableAccount":"13168550964","verifiableAccountType":1,"purpose":1} ${reps} Post On Session ZTBT uec/get/auth-captcha ${value.encode('utf-8')} log ${reps.json()} sleep 5 Connect to database #正式环境数据库获取验证码 Connect To Database Using Custom Params pymysql database='user_enterprise_center', host='rm-wz9it4fs5tk7n4tm1zo.mysql.rds.aliyuncs.com', user='uec_root', password='@qniaouecroot88', port=3306 #连接uec数据库 ${Verification Code1} Query SELECT code FROM user_enterprise_center.qn_captcha WHERE verifiable_account LIKE '%13168550964%' ORDER BY id DESC LIMIT 0,1 ${text_code} Set Variable ${Verification Code1[0][0]} Set Global Variable ${text_code} Disconnect From Database userlogin [Setup] #验证码登录 Create Session ZTBT https://api-client-uec.qniao.cn ${header} #${data} Create Dictionary account=13168550964 captcha=${text_code} accountType=2 ${data} Set Variable {"accountType":2,"password":null,"account":"13168550964","captcha":"${text_code}"} ${respones} POST On Session ZTBT uec/authorize/by-captcha ${data.encode('utf-8')} log ${respones.status_code} log ${respones.json()} ${token} Get From Dictionary ${respones.json()["data"]} token #log ${respones.json()["data"]["token"]} Set Global Variable ${token} [Teardown] login-token #${header} Create Dictionary content-type=application/json X-APP-ID=470236309865238528 Create Session ZTBT ${url} ${header} ${token1} Create Dictionary loginToken=${token} ${reps} Post On Session ZTBT recycle-user-center/authorize/get/product-line-token/by/login-token json=${token1} ${gettoken} Get From Dictionary ${reps.json()["data"]} token #获取token ${userId} Get From Dictionary ${reps.json()["data"]} userId #获取用户id log ${reps.json()["data"]["token"]} Set Global Variable ${gettoken} Set Global Variable ${userId} getuserinfo #获取用户信息 ${header} Create Dictionary content-type=application/json X-APP-ID=470236309865238528 Authorization=${gettoken} Create Session baseinfo ${url} ${header} ${reps} Get On Session baseinfo recycle-service/user/get/base-info ${realName} Get From Dictionary ${reps.json()["data"]} realName #获取实名 ${userId} Get From Dictionary ${reps.json()["data"]} userId #获取用户id Set Global Variable ${realName} Set Global Variable ${userId}