Postman之Pre-request Script 使用详解
postman 详解 request script Pre 使用
2023-09-11 14:16:34 时间
Pre-request Script 简介
- Pre-request Script是集合中请求发送之前需要执行的代码片段
- 请求参数中包含一个随机数或者请求header中包括一个时间戳,或者你的请求参数需要加密
给Request添加Pre-request Script
下面看一个案例:
1.这里就是对token进行了MD5加密,并打印
2.获取方式
3.常用的
pm.globals.unset("variable_key"); 清除全局变量
pm.environment.unset("variable_key"); 清除环境变量
pm.globals.get("variable_key"); 获取全局变量
pm.variables.get("variable_key"); 获取一个变量
pm.environment.get("variable_key"); 获取环境变量
pm.sendRequest("https://postman-echo.com/get", function (err, response) {
console.log(response.json());
}); 发送一个请求
pm.globals.set("variable_key", "variable_value"); 设置环境变量
更多学习内容关注:
相关文章
- Postman 使用方法详解
- Postman代码测试工具如何用?
- 最新版 Postman 使用秘籍
- Postman请求数据类型
- Postman工具之接口测试必学的几个关键点,你知道吗?
- ES——使用Postman连接Elasticsearch
- postman测试传入List<String>参数方式
- postman中 form-data、x-www-form-urlencoded、raw、binary的区别
- [转]Postman接口&压力测试
- postman的使用方法详解!最全面的教程
- json转 PostMan bulk Edit application/x-www-form-urlencoded 需要的格式
- 软件测试案例|使用PostMan对getWeather接口进行关联测试
- SoapUI、Postman测试WebService
- postman系列
- postman如何重置账号的密码