首页 > 其他分享 >Postman实现变量自增循环执行接口

Postman实现变量自增循环执行接口

时间:2023-05-04 10:13:23浏览次数:32  
标签:自增 Postman temp 接口 全局变量 postman

设置globals全局变量,如下图设置的n,配置初始值为1或者为其它值

 在接口中添加变量

 在Pre-request Script中设置自增的脚本

var temp = parseInt(postman.getGlobalVariable("n"));  #先获取全局变量n并赋值为temp
temp += 1; #temp自增1
postman.setGlobalVariable("n", temp); #再将自增后temp的值赋给n 

结果如下,从2开始依次获取n的值

 

 

标签:自增,Postman,temp,接口,全局变量,postman
From: https://www.cnblogs.com/roselearn/p/17370216.html

相关文章