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

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

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

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

//设置随机取值

var randomItem = myList[Math.floor(Math.random() * myList.length)]

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

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

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

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

//设置随机取值

var randomItem = array[Math.floor(Math.random() * array.length)]

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

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

相关推荐
AI_567821 小时前
Postman接口测试提速技巧:批量请求+智能断言实践
测试工具·lua·postman
Warren981 天前
Pytest Fixture 作用域与接口测试 Token 污染问题实战解析
功能测试·面试·单元测试·集成测试·pytest·postman·模块测试
弹简特1 天前
【JavaEE06-后端部分】SpringMVC01-Spring MVC第一大核心URL 路由映射【建立连接】与 Postman 接口测试详解
java·spring boot·测试工具·spring·postman
一念一花一世界2 天前
接口管理工具选型指南:Postman vs swagger vs PostIn
postman·swagger·postin·接口管理工具
今天小迪敲代码了吗3 天前
【自学】接口测试
postman
小王不爱笑1324 天前
Postman 使用教程
测试工具·lua·postman
程序员杰哥4 天前
Chrome浏览器+Postman做接口测试
自动化测试·软件测试·python·测试工具·测试用例·接口测试·postman
程序员小远6 天前
使用Postman进行一次完整的接口测试
自动化测试·软件测试·python·测试工具·测试用例·接口测试·postman
nangonghen7 天前
centos 7.9安装postman v9.31.0
centos·api·postman