*** Settings ***
Library DatabaseLibrary
Library requests
Library RequestsLibrary
Library Collections
Library String
Library XML
Library OperatingSystem
Library OperatingSystem
*** Test Cases ***
anything
[Setup] log 这里要开始了哦 # 这里要开始了哦
Comment get request请求
Comment 接口返回json处理方式
Create Session api http://192.168.88.147:8080
${phone} Set Variable 18659206199
${data} Set Variable reqStr={"phone":${phone},"type":"0"}
${123} Post Request api plot-module/realtor/user/40141/V1.0.0 ${data}
Should Be Equal As Strings ${123.status_code} 200
log ${123.status_code}
${123.status_code} ${test}= Run Keyword And Ignore Error log 打开四大护法开始发生口角发啊使得开发商的分开杀的反馈ashkenazi
log ${123.status_code}
Run Keyword If '${123.status_code}'=='200' log 通过200
Run Keyword Unless '${123.status_code}'=='PASS' log 通过PASS
Fail 执行到这里截至
${resquestdata} To Json ${123.content}
${key} Get Dictionary Keys ${resquestdata}
log ${key}
${items} Get Dictionary Items ${resquestdata}
${values} Get Dictionary Values ${resquestdata}
${LOG_FILE} ${items}
log ${values}
Delete All Sessions
Comment 接口返回xml处理方式,要在request的header里加一个accpet=application/xml,此时返回的是xml格式
${dic} Create Dictionary accp=application/xml
Comment post request请求,需要在header中加一项Content-Type=application/x-www-form-urlencoded,这种是最常见的post请求数据的方式
${dict} Create Dictionary Content-Type=application/x-www-form-urlencoded
#builtln之run keyword的使用
#Catenate 链接 \ \ 分离
${str1} Catenate hello word
${str2} Catenate SEPARATOR=------- hello word
${str3} Catenate SEPARATOR= hello word
${var222} Set Variable 我是Continue For Loop,如果值相等则退出当前循环,如果值不相当则继续循环
#Continue For Loop
: FOR ${var222} IN @{values}
\ Run Keyword If 'continue'=='continue' Continue For Loop
\ ... ELSE log asdhfkadkahfa
\ #Exit For Loop #退出循环
#Continue For Loop If
: FOR ${var222} IN range(1)
\ Continue For Loop If '${var222}'=='continue'
\ log 速度发货咯
#fail 退出执行
${len123} Set Variable hello world
Get Length ${len123}
#Get Library Instance DatabaseLibrary
${time} Get Time
${secs} Get Time epoch
${year} Get Time return year
${yyyy} ${mm} ${dd} Get Time year,month,day
@{time} Get Time year month day hour min sec
${y} ${s} Get Time seconds and year
#Get Variable Value
${x} Get Variable Value ${len123}
${yy} Get Variables ${len123}
Log To Console Message starts here and is no_newline=true
Log To Console Hello, console!
#Pass Execution dsafasdfasfds
#Run Keyword If '${len123}'=='hello world' Pass Execution Negative values are cool.
#Pass Execution If '${len123}'=='hello world' ddssd电风扇士大夫
${escaped} Regexp Escape ${len123}
#Repeat Keyword 5 times ${len123}
${sstatus} ${123.status_code}=200 Run Keyword And Ignore Error log 啊多少卡撒来得及
Run Keyword If ${sstatus}==200 log pass
Run Keyword And Return If ${sstatus}==200 log error
[Teardown] log 这里要结束了哦 # 这里要结束了哦