Apache JMeter Script Recording with the JMeter Proxy Recorder


Example

JMeter also enables you to manually configure your workspace. It’s more complex, but you can make the scripts fit your exact needs.

Configure your browser proxy

  1. Configure your browser, as described in chapter 1.

Configure JMeter

The “WorkBench” branch can be used as a temporary workspace for creating scripts. Bear in mind that entries added to this section will not be saved with the test plan. Therefore, if you want to reuse the same recording configuration in the future, you will need to copy and paste it to the “Test Plan” section.

  1. Add “Recording Controller” to “WorkBench”: Right click on “WorkBench” -> “Add” -> “Logic Controller” -> “Recording Controller”

enter image description here

  1. Add “HTTP(S) Test Script Recorder” to the same “WorkBench”: Right click on “WorkBench” -> “Add” -> “Non-Test Elements” -> “HTTP(S) Test Script Recorder”

enter image description here

  1. On the “HTTP(S) Test Script Recorder” configuration page in “Global Settings: Port”, you need to put the same port that is specified into your browser’s proxy configuration, for example 8080.

  2. If you want to exclude requests to specific resources, you can use the “URL Patterns to Exclude” section. This can be useful if you want to include only the types of content you want to request (e.g. *.html, *.php, etc) or to exclude the types of content you do not want to request (e.g. *.jpg, *.png, *.js, etc).

When would we use this? For example, when recording a script that calls a third-party application or when testing a server-side script, you might not want to download assets since they might clutter up your tests and consume bandwidth, or you might want to record certain requests from a certain path.

The most common exclude patterns are: “..png“, “..jpg“, “..gif“, “..css”, “..js”. You can also combine different patterns together. This combined pattern should get rid of all redundant requests that might distract you from important ones: “..(bmp|css|js|gif|ico|jpe?g|png|swf|woff)”

enter image description here

  1. On the other hand, you might want to mimic the complete browser behavior and include the loading of all resources. In this case, it’s not necessary to exclude URL patterns. Keep in mind through that the browser downloads all embedded resources from the requested page and that it has a caching mechanism, which might affect result performance.

In this case, it is recommended to download all the embedded resources in the script: Right click on “Test Plan” -> “Add” -> “Config Element” -> “HTTP Request Defaults” -> “Advanced” -> select “Retrieve All Embedded Resources” checkbox.

  1. To make JMeter behave more like a real browser it is recommended to add the “HTTP Cache Manager”, which lets you simulate browser caching functionality in your performance tests. Right click on “Test Plan” -> “Add” -> “Config Element” -> “HTTP Cache Manager”.

  2. Now click on the ‘Start’ button, which is at the bottom of the “HTTP(S) Test Script Recorder” page, and go through the web application workflow you want to test. When you go back to JMeter, you should see all the captured requests from your browser under the “Recording Controller”.

enter image description here