info@pragmatictesters.com +94 11 253 8512

In this post we will go through ten ways to improve the efficency in creating JMeter test scripts (JMX).

  1. Use a proxy switcher plugin in web browser
  2. Extend the security certificate validity period
  3. Use browser’s private window
  4. Save the responses during test recording
  5. Create a custom recording templates
  6. Use filters to reduce clutters in the recorded script
  7. Define the global variables in a User Defined Variables component
  8. Configure the HTTP request default with default configuration
  9. Copy the files to be uploaded to JMeter working directory
  10. Create Test Fragments

1. Use a Proxy Switcher Plugin

You need to configure your browser to send requests through the JMeter proxy in recording scripts with HTTP(s) Test Script Recorder. The number of steps invoved in swtching and configuring can be reduced with a proxy switcher plugin.

If you are using Firefox for recording you have number of plugins available. I am using the Proxy Switcher by Allan.

You can switch to the proxy with just two clicks.

2. Extend the Validity Period of Certificate

The validity period of JMeter CA certificate is seven days by default. You will have to reinstall a new certificat after every seven days. You can set higher value for the validaty period of the certificate and continue to record the scripts without frequent reinstalation of CA certifcate.

  1. Deleted the existing JMeter CA certificate and the key store file in the {JMeter_Home}/bin folder
  2. Uninstall the JMeter CA certiifcate on the browser
  3. Set the property to extend the validity period in user.properties file
  4. Start JMeter IDE
  5. Add a recording template and start the JMeter proxy

You will see the extended period in the popup window.

New certificate with the extended period will be created in {JMeter_Home}/bin

I have demonstared recording HTTPS traffice with the HTTP(S) Test Script Recorder in the following video. Extending the validity period of the certificate is included.

3. Use Browser’s Private Window

It is important to clear the browser cache before the test script recording to ensure requests are sent to the target server. Clearning the cache involve several steps. You can a new private window and use it for test script recording.

Optionally you can refresh the browser window if the requests are not recorded.

4. Save Responses During Test Script Recording

You will need the responses to correlate the values (e.g sesssion variables) after the test script recording. Hence it is improtant to save the responses to a file for later use.

Provide a uniqe name for the test result file to distinguish the result file from other test resulsts. Add a listener (e.g View Result Tree, Save Response to file) to the test script recorder and set the file name.

You can define the recoding output file when the recording template is opened too.

5. Creating Custom Templates

You can create custom recording templates by extending the existing recording templates.

6. Use Filters to Reduce Clutters in the Test Scripts

JMeter will not record all the requests sent through the JMeter proxy by default. JMeter proxy if pre-configured with the filters.

You can configure the Recorder to include the URL patterns.

7. Define the Variable in UDV component

Test Script Recorder replaces the values with the variables defined in the User Defined Variable component(s). For example you can define the scheme and server in the UDV.

8. Configure HTTP Request Default

Set the HTTP Reuest Defult in the recording test plan with the common settings to be shared among all the HTTP Requests

Recorded HTTP Requests will have proptocol and Server Name blank.

You can replace the values in the with the respective variables defined in the user defined variables controller.

If you set the variables instead of values before the recording all the HTTP requests will have the variables. Hence set the default values in the HTTP Request Default before the recording.

9. Copy Files to be Uploaded to JMeter working Directory

If your are planning to record a file upload ensure they are in the JMeter working directory.

Some browsers (e.g. Firefox and Opera) don’t include the full name of a file when uploading files. This can cause the JMeter proxy server to fail. One solution is to ensure that any files to be uploaded are in the JMeter working directory, either by copying the files there or by starting JMeter in the directory containing the files.

The file location can be changed later if required.

10. Creating Test Fragments

You can save frequently used Jmeter components or group of components with their configuration as Test Fragments and merge them with test plans later.

About Pragmatic

Pragmatic Test Labs is a software testing service provider. We provide performance testing services , JMeter training in addition to the other testing services.

Pragmatic Test Labs has partnered with Redline13 to provide cost effective distributed testing services.

Please contact janesh@pragmatictesters.com for more details

Author: Janesh Kodikara

Performance Tester | JMeter Trainer | Software Testing Service Provider

Your Turn To Talk

Leave a reply:

Your email address will not be published.