When I started learning performance testing couple of years ago, I was skeptical about how to download files using Apache JMeter or HP LoadRunner. Downloading files is pure client side activity. When you click on the file name or Download button, pop-up would generate from the OS. Once you click on Open or Save button, the file will get stored in your local disk.
E.g. In below snapshot, when you click on the attachment, you would get a Save As dialog box.
To download attachment using Apache JMeter, add a HTTP Request Sampler as shown below.
When you execute the test plan, in View Results Tree, you can see below response data from the server.
This will not download the desired file to your local disk. We will see how to download files using Apache JMeter.
To download files, you need to add Save Responses to a file sampler to your test plan. Below are my settings in my test plan.
Now execute the test plan and go to your JMETER_FOLDER\bin\. You could see the attachment which got downloaded as shown below.
EVENTTARGET has which control triggered the action. E.g. when you click on Link 1, the id of the control Link 1 will get passed in the __doPostBack function.
EVENTARGUMENT has additional data associated with the control i.e. in this case, it will trigger the download process.
In this case, you will not have direct link to download the files from the website. When you click on the link, doPostBack function triggers with the control and the argument. It is not the GET call, it is POST call. In the JMeter test plan, you need to add HTTP Request Sampler for POST call and pass at least two arguments as shown below.
Usually I use Fiddler tool to identify what value is being passed. In some instances, you may need to pass following arguments: __VIEWSTATE, __VIEWSTATEGENERATOR, and __EVENTVALIDATION.
If you execute the script, you can see the file which you want to download will get stored in the bin folder. To download the script, please create a pull request at https://github.com/QAInsights/JMeter-Script
NOTE: The above script has been created only for educational purpose, do not use in the production application/site/URL. Use at your risk, we are not responsible for any consequences.
- Measuring Client-side performance using Performance APIs - September 19, 2017
- Unboxing HPE LoadRunner 12.55 - August 20, 2017
- Measure Client-side Performance using Lighthouse - August 10, 2017
- Perf Calculator – free iOS app for performance testers - July 16, 2017
- How to performance test AngularJS or ReactJS applications? - June 25, 2017