分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 前端开发

Jmeter 通过json Extracted 来获取 指定的值的id

发布时间:2023-09-06 02:29责任编辑:白小东关键词:jsjson

在没有 精确或模糊查询的接口时可以使用jmeter 获取指定的值的ID

 1 import java.lang.String ; 2 String getTargetName="iphone632g"; 3 //判读相应结果中是否包含指定值:iphone632g 4 boolean containsCategory=prev.getResponseDataAsString().contains(getTargetName); 5 vars.putObject("containsCategory",containsCategory); 6 if(containsCategory){ 7 String [] categoryNameSplit="${categoryName_ALL}".split(",") ; 8 String [] categoryIDSplit = "${categoryID_ALL}".split(","); 9 for (int i=0 ; i<categoryNameSplit.length ;i++ ?) {10 //假如找到指定的分类就将该分类的id put 到变量中去 ; ??????????????????????11 ???????if (categoryNameSplit[i].equals(getTargetName)) {12 ???????????log.info("i=========="+String.valueOf(i));13 ???????????log.info("categoryIDSplit["+i+"]="+categoryIDSplit[i]);14 ???????????vars.put("categoryId",categoryIDSplit[i]);15 ???????????break ;16 ???????}17 ???}18 ????????}


19 ????
 1 log.info("${__jexl2(${mobilePhone}*2+4,)}"); 2 int a=${__jexl2(3*2+4,)}; 3 Integer b=${__jexl2(3*2+4,)}+${__jexl2(3*2+4,)}; 4 Integer b1=${__jexl2(${pim_interfaceType}+${pim_interfaceType})}; 5 log.info("b1=="+b1); 6 //${__jexl2(,)}+${__jexl2(,)} 返回结果可以是String 类型 或者 Integer 类型; 7 String value ="${__jexl2(3*2+4,)}+${__jexl2(3*2+4,)}" ; 8 log.info("value="+value); 9 //String + Integer10 String value1 ="${__jexl2(3*2+4,)}"+${__jexl2(3*2+4,)} ;11 log.info("value1="+value1);12 Integer createOrderAfterlockQty3=Integer.parseInt("1")+${__jexl2(${quantity})};13 log.info("xxxxxxxxxxxxxxx=="+createOrderAfterlockQty3);14 String concatItemId="\""+"${itemId_all}".replace(",", "\",\"")+"\"" ;15 log.info("concatItemId="+concatItemId);

Jmeter 通过json Extracted 来获取 指定的值的id

原文地址:https://www.cnblogs.com/linbo3168/p/10245821.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved