JMeter随机上传附件

方法一:

1.添加一个前置Beanshell 

2.输入代码:
File folder = new File("/path/to/your/folder/with/audiofiles");
File[] audioFiles = folder.listFiles();
Random rnd = new Random();
vars.put("CURRENT_FILE", audioFiles[rnd.nextInt(audioFiles.length)].getAbsolutePath());
3.在需要的地方使用变量${CURRENT_FILE}
 
方法二:
1.对所有文件批量重命名,如yinyue1.mp3,yinyue2.mp3……
2.在文件地址中输入:c:\path\to\yinyue${__Random(1,100)}.mp3
 
原文:https://www.cnblogs.com/songzhenhua/p/10034189.html
posted @ 2020-12-03 11:11  hushuer  阅读(177)  评论(0编辑  收藏  举报