How to select a random dynamic value using Regular Expression Extractor in JMeter?
This is a common scenario to get more than one dynamic value in a response which satisfies a regular expression and passes a random value in the next request. Let’s consider a performance tester uses a regular expression token bookName=”(.*?)” to capture the name of all the books present in the response. But he wants to pass any one name of the book in the next request.
So, there are 3 ways to pick a dynamic value randomly using Regular expression. As you can choose any one of them but you should have knowledge of all the methods.
1. Keep Match No. 0 (as suggested by JMeter)
This is the best and most recommended way to fetch a random dynamic value from the list of extracted values through regular expression. You can provide 0 to the Match No. field which is suggested by JMeter also.
2. Keep Match No. Blank
If you keep Match No. attribute value blank then it will instruct JMeter to choose a random value from a list of values fetched by a regular expression.
3. Using the Random function
In this method, you need to define JMeter’s random function and pass min, max and variable name (optional) as a value of Match No. field. The random function generates a random value within the specified range and passes into the Match No. field. The only limitation of this method is that you should know how many dynamic values are present in the response so that the max value attribute can be provided in the Random function.
You may be interested: