jmeter获取响应数据中参数值的常用方式(JSON提取器 、正则表达式提取器 、XPath提取器 、Bean Shell PostProcessor)

 JSON提取器:

$.Data[0].CartItems[0].UID

 

XPath提取器:

返回数据格式是HTML的时候,选择使用此种方式。

//input[@id='storageId']/@value

 

 

正则表达式提取器:

图中Field to check勾选的是Response Headers,获取的是请求头里的参数值。

 

Bean Shell PostProcessor脚本获取方式:

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;


String jsonContent = prev.getResponseDataAsString();

JSONObject response = JSON.parseObject(jsonContent);
JSONArray phaseList = response.getJSONArray("phaseList");
JSONObject phase = phaseList.getJSONObject(0);
String ChannelOrderNo = phase.getString("ChannelOrderNo");

vars.put("ChannelOrderNo", ChannelOrderNo);

 

posted @ 2019-01-09 16:55  渠晶!  阅读(1774)  评论(0编辑  收藏  举报