标签:none loading == webkit tca on() res htm home
1.项目中添加.env的文件
2.在项目中使用${.env(变量名)}进行使用
- config: name: "phpwind论坛的首页模拟" base_url: ${ENV(URL)} requests: headers: "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9" "Accept-Encoding": "gzip, deflate" "Accept-Language": "zh-CN,zh;q=0.9" "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36" export: - code - info - contenttype - content - test: name: "phpwind论坛的首页模拟" request: url: "/phpwind/" method: GET extract: - code: status_code - info: reason - contenttype: headers.Content-Type - content: ‘title="(.+?)">biaoti826</a>‘ validate: - eq: ["status_code",200] - str_eq: [$content,‘biaoti826‘]
1.在debugtalk.py中编写的方法可以在httprunner中的yml文件中使用(${方法名})
import requests def get_token_id(): get_param_data ={‘grant_type‘: ‘client_credential‘, ‘appid‘: ‘wxec83eaada223a9c8‘, ‘secret‘: ‘1867d7f1cabb3bafae0b7304e8251a09‘} response = requests.get(url=‘https://api.weixin.qq.com/cgi-bin/token‘, params=get_param_data) return response.json()[‘access_token‘] if __name__ == ‘__main__‘: print(get_token_id())
# debugtalk使用 - config: name: "获取token -- 用户管理~查看粉丝基本信息操作" base_url: "https://api.weixin.qq.com" variables: - tokenid: ${get_token_id()} - test: name: "查看粉丝基本信息" request: url: "/cgi-bin/user/info" method: GET params: access_token: $tokenid openid: "od-53v0GMqGTEiPY-QC549RTXkCk" lang: zh_CN validate: - eq: [content.language,zh_CN]
1.既可以写在config中,也可以写在test中
- config: name: "获取token -- 用户管理~查看粉丝基本信息操作" base_url: "https://api.weixin.qq.com" variables: - tokenid: ${get_token_id()} setup_hooks: - ${setup_case()} teardown_hooks: - ${teardown_case()} - test: name: "查看粉丝基本信息" request: url: "/cgi-bin/user/info" method: GET params: access_token: $tokenid openid: "od-53v0GMqGTEiPY-QC549RTXkCk" lang: zh_CN setup_hooks: - ${setup_step()} teardown_hooks: - ${teardown_step()} validate: - eq: [content.language,zh_CN]
方法一:
1.新建test_suites文件夹
2.新建yaml文件如下
config: name: "test suite" testcases: - name: "Create tags" testcase: testcases\httprunnerhomework02\create_tag.yml parameters: tag_name: [‘test11‘,‘test12‘,‘test13‘,‘test14‘,‘test15‘,‘test16‘,‘test17‘,‘test18‘,‘test19‘,‘test20‘]
3.使用 hrun test_suites\yml文件执行
httprunner 环境变量、Debugtalk辅助函数、set/tear down_hooks使用、参数化
标签:none loading == webkit tca on() res htm home
原文地址:https://www.cnblogs.com/ClownAlin/p/13143364.html