当前位置:网站首页>postman预处理/前置条件Pre-request
postman预处理/前置条件Pre-request
2022-06-29 06:39:00 【王大大、】
使用动态变量
方法一:
引用时间戳变量:{ {$timestamp}}可以动态生成请求的参数
方法二:{ {$randomInt}}:0到1000之间的随机整数
方法三:{ {$guid}} :v4样式的guid生成类似 d1a78ce0-757a-4cd6-91e5-15ca1b340dc7 这种随机值,随机性更强一些
获取请求参数,预处理

evn_username变量在Pre-request-Script脚本里面定义
//获取时间戳
var timestrip = Math.round(new Data()/1000).toString()
console.log(timestrip);
//设置环境变量evn_username的值
pm.environment.set("evn_username",'test'_Math.round(new Date()/1000));
常用Pre-request Script 代码
//清除全局变量
pm.globals.unset("variable_key");
//清除环境变量
pm.environment.unset("variable_key");
//获取全局变量
pm.globals.get("variable_key");
//获取一个变量
pm.variable.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");
可在右边直接生成
边栏推荐
- 498. 对角线遍历(模拟)
- jmeter 用beanshell导入自己jar包老是查找不到
- 蓝桥杯——13届第二批试题解析
- 循环嵌套问题:为什么大循环在内,小循环在外可以提高程序的运行效率
- Spark RDD case: Statistics of daily new users
- Blue Bridge Cup -- Analysis of the second batch of test questions of the 13th session
- Matlab Simulink simulation and analysis of power grid sweep frequency
- 1032 Sharing
- MFC中利用CDockablePane实现悬浮窗
- KingbbaseES V8R6集群维护案例之---集群之间数据迁移
猜你喜欢

KingbaseES V8R6集群维护案例之--单实例数据迁移到集群案例

Blue Bridge Cup -- Analysis of the second batch of test questions of the 13th session
如何看待软件测试培训?你需要培训吗?

施努卡:什么是视觉定位系统 视觉定位系统的工作原理

Perceiving healthy life, enabling boundless connection -- contributing to openharmony 3.1 ecological construction

systemd 管理node-exporter

【科普资料】从科学精神到科学知识的材料

详解Autosar Arxml中的CANFD报文及格式

1183:病人排队

Appium自动化测试基础 — ADB常用命令(二)
随机推荐
施努卡:3d机器视觉检测系统 3d视觉检测应用行业
systemd 管理node-exporter
KingbaseES 中select distinct on 语句
Reflection modification final
Appium自动化测试基础 — ADB常用命令(二)
[translation] E-Cloud. Large scale CDN using kubeedge
感知健康生活 赋能无界连接 ——为OpenHarmony 3.1生态构建贡献芯海力量
【工控老马】基于西门子S7-200PLC的跑马灯控制系统的设计方案详解
如何给下属进行授权?
Markdown skill tree (7): separator and reference
Markdown skill tree (8): code blocks
道闸控制器通讯协议
Markdown skill tree (1): introduction to markdown
What you should know about databases
TF.Slim的repeat和stack操作
循环嵌套问题:为什么大循环在内,小循环在外可以提高程序的运行效率
SAP UI5 初学 ( 一 )、简介
查看tensorflow是否支持GPU,以及测试程序
Schnuka: 3D machine vision inspection system 3D vision inspection application industry
ES中配置ext.dic文件不生效的原因