A04_HttpRunner通用_02_提取数据_01_extract 关键字简要说明
HttpRunner 编写用例的时候,支持从响应中提取需要的数据,赋值给变量或者进行断言等相关操作。
![795365b2f3e6d7f40ac6da6ce6a4de7a.png](https://i-blog.csdnimg.cn/blog_migrate/8ff45b43c077851ae1b4d26ad1ffb495.jpeg)
提取数据关键字:extract
支持的提取方式:
- regex 方式,通过正则表达式从 HTML 文本中提取指定内容。
如:
(.*)- delemeter 方式,通过分隔符的方式从 JSON 或者 HTML 文本中获取内容。
如: content.data.authCodeToken
- jsonpath 方式,通过 jsonpath 表达式语法从 JSON 实体中提取内容。
如: $..price
httprunner-2.5.5httprunneresponse.py:
三种提取方式对应的源码函数
class ResponseObject(object): def _extract_field_with_jsonpath(self, field) def _extract_field_with_regex(self, field) def _extract_field_with_delimiter
另外,关于 HttpRunner 的各种问题,在GitHub的issues区域中查看,下图就是新添加 jsonpath 的反馈说明:
https://github.com/httprunner/httprunner/issues
![dd080aa0d7fe740363954bc81a156f92.png](https://i-blog.csdnimg.cn/blog_migrate/b001f5850a4acfff133e708548ded492.jpeg)
GitHub issues 中关于添加 jsonpath 表达式方法的说明