一、先用fiddler抓包,获取导出IP路径
二、添加配置元件计数器
从1开始到99为止,步长为1,格式为两位数,引用名称为index
三、添加后置处理器BeanShell PostProcessor
脚本内容为:
//JMeter的内置API:prev.getResponseData()获取请求的响应内容
byte[] responseData = prev.getResponseData();
//导出的excel存放位置
private String filePath = "D:/apache-jmeter-5.2.1/导出-${index}.xls";
BufferedOutputStream bos = null;
FileOutputStream fos = null;
File file = null;
try {
File file = new File(filePath);
fos = new FileOutputStream(file); //不添加参数true,以非追加的方式添加内容
bos = new BufferedOutputStream(fos);
bos.write(responseData);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (bos != null) {
try {
bos.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
if (fos != null) {
try {
fos.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
注意:Synchronizing Timer控件——在这里进行并发控制
运行结果:
导出-01.xls----》导出了全部内容
导出-001.xls----》导出了选中的内容