1.进入RIDE可视化界面。File-->New Project,新建项目
2.层级管理。
3.新建测试包。选中项目,右键点击New Suite
4.新建测试页。右键点击New Suite
5.新建测试用例。
6.pip命令安装python第三方依赖。
7.RIDE界面导入依赖包。
8.1新建post请求
*** Settings ***
Library RequestsLibrary
Library Collections
Resource ../login/Keyword.txt
*** Variables ***
${new_product_data} {"appInfoIds":[18],"appPkName":"ws测试","appPkDesc":"测试","isVisible":0,"isQualified":true}
${new_product_path} /consoleapi/console/app-pk
*** Test Cases ***
Class_01
${token} Get_token 管理员
Create Session even ${qa}
${headers} Create Dictionary Content-Type=application/json; charset=UTF-8 token=${token}
${data} To Json ${new_product_data}
${r} Post Request event ${new_product_path} ${data} headers=${headers}
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} Success
${sta} Get From Dictionary ${dict} code
${status} Evaluate int(200)
Should Be Equal ${sta} ${status}
8.2新建get请求
*** Settings ***
Library RequestsLibrary
Library Collections
Resource ../login/Keyword.txt
Resource poruct_keys.txt
*** Variables ***
${find_product_data} {"appPackageName":"ws测试产品","pageSize":6,"pageNum":1}
${find_product_path} /consoleapi/console/app-pk
*** Test Cases ***
Class_01
${token} Get_token 锱云管理员
Create Session even ${qa}
${headers} Create Dictionary Content-Type=application/json; charset=UTF-8 token=${token}
${data} To Json ${find_product_data}
${r} Get Request event ${find_product_path} headers=${headers} params=${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} Success
${rp_data} Get From Dictionary ${dict} data
${tot} Get From Dictionary ${rp_data} total
${totals} Evaluate int(1)
Should Be Equal ${tot} ${totals}
${sta} Get From Dictionary ${dict} code
${status} Evaluate int(200)
Should Be Equal ${sta} ${status}
9.新建关键字。测试包右键-->New Resource
10.新建自定义变量。测试页-->Add Scalar
11.导入自定义关键字。
12.导入的自定义关键字.txt文件,文件中的自定义变量也可以使用