The easiest way to set up JMeter for recording is by using the Templates feature, by performing the following steps:
- From JMeter’s main menu, choose File -> Templates -> Recording
- Click the “Create” button
- 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 cause the recording to be successful.
The same applies to the recorded scenario replay. Here you have 2 options:
- Provide the full path to any file which you want to upload
- 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.