{"id":1117,"date":"2017-02-28T15:02:32","date_gmt":"2017-02-28T15:02:32","guid":{"rendered":"https:\/\/loadfocus.com\/blog\/?p=1117"},"modified":"2024-02-26T08:06:15","modified_gmt":"2024-02-26T08:06:15","slug":"how-to-save-apache-jmeter-results-to-a-csv-file-or-xml-file","status":"publish","type":"post","link":"https:\/\/loadfocus.com\/blog\/2017\/02\/how-to-save-apache-jmeter-results-to-a-csv-file-or-xml-file","title":{"rendered":"How to Save Apache JMeter Results to a CSV file or XML file?"},"content":{"rendered":"<span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\"><\/span> <span class=\"rt-time\"> 2<\/span> <span class=\"rt-label rt-postfix\">minutes read<\/span><\/span><p class=\"lead\">Here are details on how to save or export the results of your Apache JMeter test script to a CSV or XML file.<\/p>\n<h3>Setup<\/h3>\n<p>1. Open Apache JMeter (here is how to <a href=\"https:\/\/loadfocus.com\/blog\/2014\/06\/24\/run-apache-jmeter-on-mac\/\">start Apache JMeter on Mac<\/a>) and right click<strong> Test Plan<\/strong> and <strong>Add -&gt; Threads (Users) -&gt; Thread Group<\/strong><br \/>\n2. Right click <strong>Thread Group<\/strong> and <strong>Add -&gt; Samplers -&gt; HTTP Request<\/strong><br \/>\n3. Add <strong>example.com<\/strong> to the Server input field of the <strong>HTTP Request<\/strong><br \/>\n4. Right click Thread Group and <strong>Add -&gt; Listeners -&gt; Aggregate Report<\/strong><\/p>\n<p>More details on <a href=\"https:\/\/loadfocus.com\/blog\/2016\/04\/13\/how-to-use-apache-jmeter-to-load-test-a-web-server\/\">how to load test a web server with Apache JMeter<\/a>.<\/p>\n<h3>Save Apache JMeter Results to a CSV file<\/h3>\n<p>1. Configure the filename in the <strong>Filename<\/strong> field of the <strong>Aggregate Report<\/strong><br \/>\ni.e.: <strong>[FULLPATH]\/results.csv<\/strong><br \/>\nwhere [FULLPATH] is the path on the disk to the directory where you want to save the Apache JMeter results.<br \/>\n2. Run the test script<br \/>\nResult<br \/>\nA file with the <strong>results.csv<\/strong> name should now be created at the path specified.<\/p>\n<h3>Save Apache JMeter Results to a XML file<\/h3>\n<p>1. Go in the <strong>Aggregate Report<\/strong> and click the <strong>Configure<\/strong> button<br \/>\n2. Check the <strong>Save as XML<\/strong> field in the top left corner.<br \/>\n3. Change the extension of the filename to XML i.e. <strong>[FULLPATH]\/results.xml<\/strong><\/p>\n<p>Result<br \/>\nA file with the results.xml name should now be created at the path specified.<\/p>\n<h3>Save results to current test script location<\/h3>\n<p>If you want to use the current test script location as the destination of your Apache JMeter test scripts, you can follow the below steps:<\/p>\n<p>1. Right click the <strong>Thread Group<\/strong> and <strong>Add -&gt; Config Element -&gt; User Defined Variables<\/strong><br \/>\n2. Add a new variable called <em>resultsfile<\/em> and for the value use the following:<\/p>\n<pre class=\"lang-js\"><code>For CSV: ${__property(user.dir)}${__BeanShell(File.separator,)}result.csv\nFor XML: ${__property(user.dir)}${__BeanShell(File.separator,)}result.xml\n<\/code><\/pre>\n<a href=\"https:\/\/d2woeiihr4s5r6.cloudfront.net\/blog\/jmeter-results.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/d2woeiihr4s5r6.cloudfront.net\/blog\/jmeter-results.png\" width=\"1196\" height=\"627\" \/><\/a>\n<p>(make sure the <strong>Save to XML<\/strong> is checkbox checked in the Aggregate Report)<\/p>\n<p>3. Go to the <strong>Aggregate Report<\/strong> and add the ${resultsfile} in the Filename field.<\/p>\n<p>Result<br \/>\nA file with the <em>results.csv<\/em> or <em>results.xml<\/em> name should now be created at the path specified.<\/p>\n<h3>Dynamic Filenames<\/h3>\n<p>In order not to overwrite the result values from the JMeter script, we can append a timestamp to the filename:<\/p>\n<pre class=\"lang-js\"><code>\nFor CSV: ${__property(user.dir)}${__BeanShell(File.separator,)}result_${__time(yyyyMMdd-HHmmss)}.csv\nFor XML: ${__property(user.dir)}${__BeanShell(File.separator,)}result_${__time(yyyyMMdd-HHmmss)}.xml\n<\/code><\/pre>\n<p>(make sure the <strong>Save to XML<\/strong> is checked in the <strong>Aggregate Report<\/strong>)<\/p>\n<p><strong>Apache JMeter note:<\/strong><br \/>\nDon&#8217;t use GUI mode for load testing, only for Test creation and Test debugging!<br \/>\nFor load testing, use NON GUI Mode &amp; adapt Java Heap to your test requirements<\/p>\n","protected":false},"excerpt":{"rendered":"<p><span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\"><\/span> <span class=\"rt-time\"> 2<\/span> <span class=\"rt-label rt-postfix\">minutes read<\/span><\/span>Here are details on how to save or export the results of your Apache JMeter test script to a CSV or XML file. Setup 1. Open Apache JMeter (here is how to start Apache JMeter on Mac) and right click Test Plan and Add -&gt; Threads (Users) -&gt; Thread Group 2. Right click Thread Group&#8230;  <a href=\"https:\/\/loadfocus.com\/blog\/2017\/02\/how-to-save-apache-jmeter-results-to-a-csv-file-or-xml-file\" class=\"more-link\" title=\"Read How to Save Apache JMeter Results to a CSV file or XML file?\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,48],"tags":[205,203,204],"class_list":["post-1117","post","type-post","status-publish","format-standard","hentry","category-apache-jmeter","category-test-automation","tag-save-aggregate-report-to-file","tag-save-jmeter-results-to-csv-file","tag-save-jmeter-results-to-xml-file"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/posts\/1117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/comments?post=1117"}],"version-history":[{"count":2,"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/posts\/1117\/revisions"}],"predecessor-version":[{"id":2977,"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/posts\/1117\/revisions\/2977"}],"wp:attachment":[{"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/media?parent=1117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/categories?post=1117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/tags?post=1117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}