How to save Jmeter Variables to csv file

为君一笑 提交于 2019-11-30 16:12:51
  1. Replace your out.write(${account_id}); stanza with out.write(vars.get("account_id"));
  2. It is better to close fstream instance as well to avoid open handles lack
  3. If you're going to reuse this file, i.e. store > 1 variable, add a separator, i.e. new line

Final code:

FileWriter fstream = new FileWriter("result.csv",true);
BufferedWriter out = new BufferedWriter(fstream);
out.write(vars.get("account_id"));
out.write(System.getProperty("line.separator"));
out.close();
fstream.close();

See How to use BeanShell: JMeter's favorite built-in component for comprehensive information on Beanshell scripting

You can use this code in your BeanShellPostProcessor. It may help You.

String acid="${account_id}";
FileWriter fstream = new FileWriter("result.csv",true);
fstream.write(acid+"\n");
fstream.close();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!