How To Upload A Test Image Functionality With JMeter?



Apache Jmeter is a common testing tool for open-source results. This blog teaches you how to upload files in JMeter’s simple to advance level definition to make you an expert in testing.

You could come up with image upload-download features in any web application in performance testing contexts.

Configuration of the JMeter Script

Initially, make sure your HTTP request is set to “POST” and check the box for Use multipart/form-data for POST”.

In the ‘Return Files with Order’ pane, here are a few significant points to consider:

  • File path – If you test locally, make sure you have the full path to the file, including the name of the file. Do not add a path to the file when using BlazeMeter, as it will automatically be put in the Jmeter/Home/Cloud folder.
  • Name parameter – This must be the same ‘name’ attribute as it appears in the root of the page, otherwise, there would be no ‘destination’ for the file.
  • Mime Form – It goes without saying, but make sure that the right one is entered. If not, it won’t function properly in the upload process.

Want to upload several files?

You would need to “parameterize” the script a little to do this. You will need to write ${imageName} instead of the image file name that you see in the ‘Send Files With Request’ window above. Next to the top of the script, add a ‘CSV Data Set Config’ feature. This will read file names from a CSV file and set them to an “imageName” variable.

File Upload with JMeter

Recording the subsequent request using the HTTP(s) Test Script Recorder is the best way to build a JMeter test plan. JMeter serves as a proxy server, collecting and translating all traffic between a web browser and the testing framework (AUT) into the appropriate HTTP requests.

JMeter has predefined models for building test plans that we can use. To set-up JMeter for recording, follow the steps below.

  • Click on File – Templates and select Template Recording.
  • Click the button called Build.
  • Using the JMeter proxy to customize your browser by supplying the IP address of the computer running JMeter as a proxy server and a proxy port.
  • To start recording, open your HTTP(S) Test Script Recorder and click on the start button.

JMeter creates a certificate file called ‘ApacheJMeterTemporaryRootCA.crt’ and stores it in JMeter’s bin directory. To catch HTTPS traffic, install this certificate on your browser. The setup is ready now. Start performing your actions in a browser and, as shown below, JMeter collects and transforms the traffic to HTTP samplers.

JMeter accurately fixed the file name, which is index.html, as you can see from the picture above, but didn’t catch the complete path to the file. Certain browsers do not submit the complete path of the file that is being submitted, this is a consequence of browser behavior. 

That is why JMeter couldn’t find the file and send it along with the submission.

By default, in its bin folder, JMeter searches for index.html. If you run the documented script, it will fail because the file in the bin folder of JMeter is not present.

The alternative is to copy the file to JMeter’s bin directory. This way, JMeter uses the relative path to pick up the file and you will have a good recording. Or, in the HTTP sampler, you can specify the absolute direction, so that JMeter selects the file from the position defined in the HTTP sampler.

Now, when you run the script, JMeter selects the absolute path file and runs the HTTP sampler.

Load Testing with JMeter

JMeter Load Testing is a testing procedure performed using a Java-based open-source desktop application load testing tool called Apache JMeter. JMeter is a critical tool for load testing that decides whether or not the web application under test can meet high load specifications. It also allows the study of the entire server under heavy load.

JMeter Performance Testing

JMeter Performance Testing is a testing approach that uses Apache JMeter to measure a web application’s performance. Performance testing JMeter helps to test both static and dynamic tools, helps to discover concurrent website users, and offers a range of performance testing graphical analysis. JMeter performance testing requires load testing and web server stress testing.

  • In performance monitoring, the Apache JMeter testing tool provides the following value.
  • You can use JMeter to evaluate both static resources, such as JavaScript frameworks and HTML, and dynamic resources, such as JSP, Servlets, and AJAX, for performance.
  • The maximum number of concurrent users your website can accommodate can be found in JMeter
  • A collection of graphical analysis of performance reports is given by JMeter.

In the JMeter tutorial, this completes the file upload handling.