Dmitri Tikhanski is a Contributing Writer to the BlazeMeter blog.

Become a JMeter and Continuous Testing Pro

Start Learning
Slack

Test Your Website Performance NOW!

arrow Please enter a URL with http(s)
Apr 27 2016

Recording File Uploads with JMeter

If you need to simulate uploading a file to application under test, the fastest way of creating a JMeter test plan is recording the corresponding request via the HTTP(S) Test Script Recorder. JMeter comes with a proxy server which captures all traffic between the browser and the application under test, and converts it into the relevant HTTP Request samplers.

 

The easiest way to setup JMeter for recording is by using the Templates feature, by performing the following steps:

 

  1. From JMeter’s main menu, choose File -> Templates -> Recording

  2. Click “Create” button

  3. Configure your browser to use the JMeter proxy providing:

 

  • The hostname or the IP address of the machine where JMeter is running as the proxy host

  • 8888 as the proxy port

 

 

Now let’s try to record the file upload. I’ll use the README file which lives in the root of the JMeter installation for this exercise.

 

 

So we’re getting the following error:

 

java.io.FileNotFoundException: README (The system cannot find the file specified)

 

Let’s take a look at the recorded request in the Test Plan:

 

 

As you can see from the image above, JMeter correctly resolved the file name which is README, but didn’t capture the full path to the file. This is a result of browser behavior, as some browsers don’t send the full path of the file which is being uploaded. That is why JMeter wasn’t able to locate the file and send it along with the request.

 

The solution is to copy the file to JMeter’s “bin” folder. This way JMeter will pick up the file using the relative path, and therefore causing the recording to be successful.

 

The same applies to the recorded scenario replay. Here you have 2 options:

 

  1. Provide the full path to any file which you want to upload

  2. Use the relative path (just filename), but in this case the file has to be in JMeter’s “bin” folder


Remember that if JMeter’s proxy doesn’t work for you for some reason, there are the following alternative options of recording a JMeter test:

 

  • Using the BlazeMeter Chrome Extension - this way you don’t need to worry about proxy configuration, SSL certificates, copying files to JMeter’s “bin” folder, etc

  • Using the BlazeMeter Recorder - your personal Cloud proxy which has “SMART” JMX mode of exporting captured requests - automatic correlation of dynamic parameters so you won’t have to develop and debug regular expressions in order to make your test work.
     

 

     
arrow Please enter a URL with http(s)

Interested in writing for our Blog?Send us a pitch!