zoukankan      html  css  js  c++  java
  • Jmeter 通过json Extracted 来获取 指定的值的id

    在没有 精确或模糊查询的接口时可以使用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 + Integer
    10 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);
  • 相关阅读:
    在ubuntu下安装phpmyadmin 出现404错误
    Jquery插件收藏
    PHP 时区设置
    Jquery动态进行图片缩略
    CSS设置图片垂直居中的方法
    解决CI框架的Disallowed Key Characters错误提示
    @Component默认是单例还是多例?
    ehcache的heap、off-heap、desk浅谈
    nginx负载均衡分配策略有哪些?
    HashSet的实现原理,简单易懂
  • 原文地址:https://www.cnblogs.com/linbo3168/p/10245821.html
Copyright © 2011-2022 走看看