JMeter – Capture Dynamic Value present in Request URL

In the correlation article of JMeter, you got detailed knowledge on:

  • What is Correlation?
  • Why correlation is required?
  • How to capture dynamic values?

The purpose of this article is to elaborate on the process of finding out the dynamic value when it is present in the request URL. This is a general scenario because most of the time dynamic value is available in the response body and you can easily identify it.

Steps to identify the dynamic value present in the request URL:

  1. Add a ‘View Results Tree’ listener under the thread group
Figure 01
  1. In the Thread Group, select the ‘Stop Thread’ option for ‘Action to be taken after a sampler error’.
  2. Make sure the input value of the Number of Threads (users), Ramp-up period (seconds), Loop Count should be 1.
Figure 02: Thread Group
  1. Click the ‘Run’ button
  2. The script may fail at a particular sampler where correlation is required.
JMeter - Capture Dynamic Value present in Request URL
Figure 03
  1. Refer to the script and click on the same sampler which is failed during the replay.
  2. In case there is no value in the Parameters and Body Data tab of the sampler then refer to the request URL in the ‘Path’ field.
  3. If you identify the value in the URL then copy it.
JMeter - Capture Dynamic Value present in Request URL
Figure 04

Step 1: Refer to the recorded ‘View Results Tree’ listener. Paste the copied value in the search field of the recorded View Results Tree listener and press the ‘Search’ button.

Step 2: JMeter will highlight the request where this value is available. Now select the very first highlighted request.

Step 3: Click the ‘Response Data’ tab.

Step 4: Under the ‘Response Data’ tab, click the ‘Response Body’ tab.

Step 5: Again paste the same value in the search field of the Response Body.

Step 6: Click the ‘Find’ button. Check the place where this dynamic value appeared in the response body. The searched value will be highlighted.  

JMeter - Capture Dynamic Value present in Request URL
Figure 05

Step 7: Once JMeter finds out the value in the response body, then copy the string in such a way so that you can write a unique regular expression.

Learn – How to write the regular expression?

Step 8: Prepare a regular expression statement which can capture the dynamic value. In this example, the regular expression statement will be:


Step 9: Verify the correctness of regular expression.

  1. To verify the correctness of the regular expression statement, write the same regular expression in the search box of the response of the sampler (Recorded View Results Tree Listener).
  2. Checkmark the ‘Regular exp.’ option.
  3. Press the ‘Find’ button


  1. You can also select the ‘RegExp Tester’ from the drop-down of the view results tree listener
  2. Paste the regular expression statement
  3. Click ‘Test’.
JMeter - Capture Dynamic Value present in Request URL
Figure 06

The result in both cases should highlight the correct dynamic value.

  1. Repeat these steps until you find all the dynamic values.

Now, the next step is implementation.

Steps to implement the correlation:

  1. For this purpose, add a regular expression extractor under the same sampler whose response contains the dynamic value and paste the regular expression statement (from step 8) in the ‘Regular Expression’ field. Also, provide the Name of the created variable along with the Template, Match No. and Default Value.

Read about ‘Regular Expression Extractor’ postprocessor

Figure 07
  1. The last step is to replace all the occurrences of dynamic values in the subsequent requests by ${<RegExVaribaleName>} syntax. Refer to the below screenshot:
Figure 08
  1. Re-run the script and verify the correctness of correlation by referring to the view results tree listener or by adding a debug sampler.

You may be interested:

Leave a Comment