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.
- #3 – LoadSter, Google Chrome, and Sonarwhal – QAInsights Podcast - April 25, 2018
- #2 QAInsights Podcast – 18.104.22.168 and many more - April 9, 2018
- QAInsights Podcasts – First Episode - March 30, 2018
- Rajini Makkal Mandram Vs Makkal Neethi Maiyam – a tech comparison - March 5, 2018
- Do not blame it on server! - February 26, 2018