Postman脚本处理各种数据的变量

一、变量是字符串里列表, 如 ""100","101","102","103","108""

//把字符串的变量处理成列表

var myList=JSON.parse(pm.environment.get('giftTabId')) #giftTabId变量名

//设置随机取值

var randomItem = myListMath.floor(Math.random() \* myList.length)

//把取得随机值赋值到新得变量名中

pm.environment.set("giftTabId_one",randomItem)

二、变量是列表,如"100","101","102","103","108"

var array=pm.environment.get('evaluationId')

//设置随机取值

var randomItem = arrayMath.floor(Math.random() \* array.length)

//把取得随机值赋值到新得变量名中

pm.environment.set("pingjia_id",randomItem)

相关推荐
Pluchon1 天前
Java个人综合项目——萌部落社区V2.0
java·python·spring·spring cloud·postman·idea
昨夜星河入梦来4 天前
postman接口测试报错503的解决方法
开发语言·postman
冷凝娇5 天前
【Postman】2026总结
测试工具·postman
降临-max8 天前
Postman----接口自动化
软件测试·功能测试·自动化·postman
测试秃头怪8 天前
postman接口测试详解
自动化测试·软件测试·python·测试工具·测试用例·接口测试·postman
减瓦9 天前
告别Postman——用VSCode优雅地发起Http请求
vscode·http·postman
Chloeis Syntax17 天前
JAVAEE初阶 --- 构造HTTP请求
网络·网络协议·http·postman
胡渠洋23 天前
postman学习
学习·测试工具·postman
胡渠洋25 天前
用python实现postman
开发语言·python·postman
啦啦啦!1 个月前
AI接口自动化测试的学习
学习·postman