1里面定义个变量2 3这里加上postman.setEnvironmentVariable("MatchID",JSON.parse(responseBody)); 这样reponsebody的这个值就会放到变量MatchID里面了 @ 其他地方就可以引用了
用jsonData接收pm返回的response的内容;第二行代码是设置pm的全局变量,set的第一个参数是全局变量的名...
fieldValue); // 将提取的值存储到全局变量中 pm.globals.set("variableName",
var jsonData = JSON.parse(responseBody);//postman.setEnvironmentVariable("key", jsonData.key);console.log(typeof(jsonData))pm.environment.set("key", jsonData.key);var jsonData = JSON.parse(responseBody);tests["Body matches string"] = responseBody.has(true); pm.test("检查请求是否包含true...
注意:这只能用来读取变量。使用setGlobalVariable()设置值 2.5测试沙箱 2.5.1测试沙箱描述 Postman测试沙箱:是一个JavaScript执行环境,可以通过JS脚本来编写pre-requist和测试脚本。 1、Pre-request script:可以修改或设置一些默认参数,在request之前执行; 2、Tests使用语言Java script,用来建议response是否满足要求; ...
pm.response.to.have.status(200); }); runner-set 打开「卡拉云kalacloud.com批量测试」合集的「Run Collection」的设置页 Iterations:这是测试组,我们 CSV 文件中有 4 组测试条目 Delay:延迟,一般填 2000 毫秒,太密集的请求,容易被服务器拒绝 Data:这里选择我们刚刚的 CSV 文件:kalacloud_users.csv 导入测试...
postman.setGlobalVariable("key","value"); Tests区域是专门对返回响应数据进行处理,例如,将接口返回的结果中的某数据设置为全局变量 //获取返回的响应值,并转化为json格式,赋给变量jsonDatavarjsonData=pm.response.json();//获取返回的uid值,赋给变量global_id存储varclaimId=jsonData.json['claimId'];//在...
postman.setEnvironmentVariable("variable_key", "variable_value"); 参数:环境变量的键值 11.判断状态码 Status code:Code is 200 对应脚本: tests["Status code is 200"] = responseCode.code != 400; 参数:状态码 12.检查code name 是否包含内容 ...
pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); pm.test("Status code name has string", function () { pm.response.to.have.status("OK"); }); pm.test("Body", function () { pm.response.to.have.body(); }); 其他方法 pm.info 对象 方法描述...
Each variable has anInitial valueandCurrent value: Initial valueis a value that's set in the element (collection, environment, or globals) where the variable is defined. This value is synced to Postman's servers, and is shared with your team when you share that element. Setting an initial...