1、jmeter获取请求参数,参数字段和参数值
import org.apache.jmeter.config.Arguments;
import java.util.Map.Entry;
Arguments args = sampler.getArguments();
Map map = args.getArgumentsAsMap();
log.info("==============:"+args.getClass().toString());
Iterator itor = map.entrySet().iterator();
while(itor.hasNext()){
Entry entry = (Entry) itor.next();
log.info("==========key:"+entry.getKey());
}
2、
-
sampler (是Samper对象) 参考http://jmeter.apache.org/api/org/apache/jmeter/samplers/Sampler.html
a)获取http请求的 url
String url = sampler.getPath();
b)获取http请求的body内容
Arguments arguments = sampler.getArguments(); // 调用时注意sampler小写
String body = arguments.getArgument(0).getValue();
备注:需要引入包import org.apache.jmeter.config.Arguments;
本文介绍如何使用JMeter获取请求参数,包括参数字段和参数值,以及如何通过Sampler对象获取HTTP请求的URL和body内容。适用于性能测试和接口测试场景。

1万+

被折叠的 条评论
为什么被折叠?



