You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
3.7 KiB
111 lines
3.7 KiB
*** Settings ***
|
|
Test Timeout 10 seconds
|
|
Library RequestsLibrary
|
|
Library Collections
|
|
Library DateTime
|
|
Library String
|
|
Library pabot.PabotLib
|
|
Library ExcelLibrary
|
|
Library urllib3
|
|
Resource 形参.txt
|
|
|
|
*** Variables ***
|
|
${num} [1,2,3]
|
|
${list} [1,2,3,4,5]
|
|
|
|
*** Test Cases ***
|
|
生成随机数
|
|
#取列表中的随机数
|
|
#${value} Evaluate random.choice(${num}) random
|
|
#log to console \nvalue: ${value}
|
|
@{list} Set Variable A B C D
|
|
FOR ${var} IN @{list}
|
|
Run Keyword If '${var}'==B Exit For Loop
|
|
log ${var}
|
|
#Set Global Variable ${var}
|
|
|
|
图片base64加密
|
|
${filepath} Set Variable E:/lyl/图片/20210805134405.jpg
|
|
${pic_base64} Evaluate base64.b64encode(open('${filepath}','rb').read()).decode('utf-8') base64
|
|
log ${pic_base64}
|
|
|
|
生成多个随机数
|
|
#获取列表内2个随机数
|
|
${rand_str} evaluate random.sample([0,1,2,3,4,5],2) random,string
|
|
|
|
条件判断后赋值
|
|
#条件判断后赋值
|
|
${a} Set Variable If 4
|
|
${a} Set Variable If '${a}'=='null' 1 2
|
|
Set Global Variable ${a}
|
|
Repeat Keyword 100 ${a}
|
|
|
|
数据断言
|
|
${data} Set Variable a
|
|
Should Be Equal ${data} a
|
|
|
|
获取时间
|
|
${datatime} Get Current Date result_format=%Y-%m-%d
|
|
${DT} Add Time To Date ${datatime} -1 day
|
|
#${str} Get Substring ${DT} 0 10
|
|
#${time_stamp} Convert Date ${datatime} epoch
|
|
#log 年:${time_stamp.year}
|
|
#Should Be Equal As Integers ${DT} 2021
|
|
|
|
重复执行测试用例
|
|
Repeat Keyword 10 times log 赋值判断
|
|
|
|
for循环
|
|
FOR ${items} IN RANGE 15
|
|
${a} Set Variable 2
|
|
${b} Evaluate ${a}+1
|
|
FOR ${index} IN RANGE 10
|
|
Exit For Loop If '${index}'=='${b}'
|
|
END
|
|
END
|
|
|
|
嵌套使用关键字
|
|
FOR ${index} IN 51 56
|
|
${a} Set Variable ${index}
|
|
END
|
|
${c} Set Variable If '${a}'=='51' 待上传磅单
|
|
'${a}'=='52' 待运营审核
|
|
'${a}'=='53' 待财务审核
|
|
'${a}'=='54' 待回款
|
|
'${a}'=='55' 已完成
|
|
|
|
数据驱动
|
|
Open Excel E:\\lyl\\Robot Framework\\Test\\111.xls
|
|
${rowcount} Get Row Count 信息
|
|
FOR ${row} IN RANGE 1 ${rowcount} #遍历从第二行开始的数据
|
|
${phonenum} Read Cell Data By Coordinates 信息 0 ${row}
|
|
${captcha} Read Cell Data By Coordinates 信息 1 ${row}
|
|
#${phoneint} Convert To Integer ${phonenum} #转换为整数
|
|
#${apach} Convert To Integer ${apach}
|
|
Exit For Loop If '${phonenum}'=='18888888888'
|
|
END
|
|
Set Global Variable ${phonenum}
|
|
Set Global Variable ${captcha}
|
|
|
|
login
|
|
参数实例化 ${phonenum} ${captcha}
|
|
|
|
*** Keywords ***
|
|
list
|
|
[Arguments] ${list}
|
|
${value} Evaluate random.choice(${num}) random
|
|
log to console \nvalue: ${value}
|
|
|
|
链接redis
|
|
#连接redis
|
|
${redis_conn}= Connect To Redis 8.135.8.221 6379 2 qnredis
|
|
#Set To Redis ${redis_conn} PAPER_MILL_ID | 01234567890 ${data}
|
|
#${data} Get From Redis ${redis_conn} *PAPER_MILL_ID496656259144093696
|
|
#${redis_data} Get From Redis ${redis_conn} PAPER_MILL_ID
|
|
${key_list}= Get Dictionary From Redis Hash ${redis_conn} PAPER_MILL_ID*
|
|
${key_list}= Get All Match Keys ${redis_conn} PAPER_MILL_ID* 50
|
|
|
|
赋值判断
|
|
${a} Set Variable If 4
|
|
${a} Set Variable If '${a}'=='null' 1 2
|
|
Set Global Variable ${a}
|