robot framework学习笔记四 : excel管理用例
2020-08-24 本文已影响0人
wenshuang_he
-
新建用户自定义变量case,并导入包ExcelLibrary
${case} -
新建用户自定义变量sheet_name
${sheet_name} -
用例中使用
具体用法
附上代码
用户自定义变量case
*** Settings ***
Library RequestsLibrary
Library Collections
Library ExcelLibrary
Library DatabaseLibrary
*** Variables ***
${case} C://Users//ziyun//Desktop//testcase//后管端用例.xls
用户自定义变量sheet_name
*** Settings ***
Resource ../sys_Keyword.txt
*** Variables ***
${sheet_name} PBOX升级计划
测试用例
*** Settings ***
Resource ../sys_Keyword.txt
Resource ./Keyword.txt
*** Variables ***
*** Test Cases ***
Class_01
Open Excel ${case}
${token} Get_token ${user}
Create Session ip ${ip}
${slx_path} Read Cell Data By Name ${sheet_name} D3
${slx_data} Read Cell Data By Name ${sheet_name} F3
${slx_msg} Read Cell Data By Name ${sheet_name} G3
${headers} Create Dictionary Content-Type=application/json; charset=UTF-8 token=${token}
${r} Get Request ip ${slx_path} headers=${headers} params=${slx_data}
Should Be Equal As Strings ${r.status_code} 200
log ${r.json()}
${dict} Set variable ${r.json()}
log --------断言结果-------
${msg} Get From Dictionary ${dict} message
Should Be Equal ${msg} ${slx_msg}
${sta} Get From Dictionary ${dict} code
${cood} Evaluate int(200)
Should Be Equal ${sta} ${cood}
${rp_data} Get From Dictionary ${dict} data
${first} Set variable ${rp_data[0]}
${name} Get From Dictionary ${first} modelName
${names} Evaluate str("基础版")
Should Be Equal As Strings ${name} ${names}
```