1.create session:创建session.作用:跨请求保持一些cookie
2.get request ,发出get请求。若使用参数组构建的url访问,需要用params=${params}
3.post request ,发出post请求。需要带params,且params=None,位于data之前。data是传参。比如:
${resp} post_request bx /oz/login params=None data=${bx_login_req} headers=${online_cookie}
4.set_suite_variable:使变量在当前套件的范围内随处可用。
set_suite_variable ${mock_url} http://${test_site_domain}.baidu.cn
类似还有:set_test_variable
5.run_keyword_if: 条件判断
run_keyword_if addition keyword 。。。。
run_keyword_if '${env}'=='test' set_suite_variable ${mock_url} http://${test_site_domain}.baidu.cn
6.connect_to_database_using_custom_params: 使用自订参数连接到数据库中
connect_to_database_using_custom_params pymysql ${test_db_connect}
test_db_connect: host='192.168.x.xx',port=3306,user='xxxx',passwd='xxxx',charset='utf8'
7.断开数据库链接disconnect_from_database
8.get_current_date
image.png
${start} get_current_date result_format='%Y-%m-%d'
${end} add_time_to_date ${start} ${renewVersions_req['time']} days result_format='%Y-%m-%d'
4.断言方式
响应码:Should Be Equal As Strings ${resp.status_code} 200
状态码:Should Be Equal As Strings {resp.json()['status']}{0}
返回信息:Should Be Equal As Strings ${resp.json()['msg']} success
返回空:Should Be Equal As Strings {resp.json()['desc']}{EMPTY}
检查返回的文字:Should Contain Any ${resp.text} 今日统计
Dictionary Should Contain Value ${resp.json()} xxxx
Should Be Equal
网友评论