You might have faced issues in writing data to excel/csv in JMeter. In this blog post, we will see How to write data to Excel/CSV in Jmeter using BeanShell scripting? By using Regular Expression Extractor, you can extract data from the response. To write extracted data to excel/csv in Jmeter, you need to use BeanShell PostProcessor sampler.
How to extract data from the response?
You can refer my slideshare presentation on how to extract data from the response.
refnum = vars.get("Reference_Number"); log.info(refnum); // if you want to log something to jmeter.log file // Pass true if you want to append to existing file // If you want to overwrite, then don't pass the second argument f = new FileOutputStream("yourpath/result.csv", true); p = new PrintStream(f); this.interpreter.setOut(p); print("Reference Number is," + refnum); f.close();
[auto_thumb width=”150″ height=”150″ link=”” lightbox=”true” align=”center” title=”How to write data to Excel CSV in Jmeter using BeanShell scripting – BeanShell PostProcessor Sample Code” alt=”How to write data to Excel CSV in Jmeter using BeanShell scripting – BeanShell PostProcessor Sample Code” iframe=”false” frame=”true” crop=”true”]http://qainsights.com/wp-content/uploads/2013/09/How-to-write-data-to-Excel-CSV-in-Jmeter-using-BeanShell-scripting-BeanShell-PostProcessor-Sample-Code.jpg[/auto_thumb]
Thanks for visiting QAInsights! Check out our new portal Testifications.com to get updates on Software Testing related certifications. We’re always posting interesting articles on QAInsights. I request you to subscribe so you don’t miss out anything.
Searching for QA Jobs Openings, check it at www.QAJobOpenings.com
Want to start a blog like this, please visit SpidyDomain to buy cheap web hosting and register domain.
- Perf Calculator – free iOS app for performance testers - July 16, 2017
- How to performance test AngularJS or ReactJS applications? - June 25, 2017
- How to run Apache JMeter tests with Visual Studio Team Services? - June 6, 2017
- Google Test Automation Conference – GTAC 2017 - June 2, 2017
- What’s new in StormRunner 2.5? - June 1, 2017