How to use "Random Variable" in JSON Extractor in Jmeter?

95 Views Asked by At

I am capturing bunch of available seat list using JSON Extractor (Please refer "1_JSON_Extractor" ) , I am using -1 to capture all the ordinals, it is working fine (Refer "2_Debug_Sampler").

I need to take the random value from the list, Instead of using 0 for Random Ordinal, I am trying to use Random Variable here,( Please refer "3_Random_variable"). But it is not working fine.

I am planning to use the the Random variable "C_Seat_1" in the place of JSON Extractor Match No and get the random value. (Please refer "4_Json_Extractor")1_JSON_Extractor .2_Debug_Sampler3_Random_variable4_Json_Extractor

Can you help ?

1

There are 1 best solutions below

1
Dmitri T On

Take a look at JMeter Test Elements Execution Order

0. Configuration elements

  1. Pre-Processors

  2. Timers

  3. Sampler

  4. Post-Processors (unless SampleResult is null)

  5. Assertions (unless SampleResult is null)

  6. Listeners (unless SampleResult is null)

Hence when Random Variable is evaluated JSON Extractor hasn't been executed yet therefore ${C_Selected_Seat_All_matchNr} is not defined

You can just go for __Random() and __V() functions combination to pick a random seat directly where required without any extra configuratino elements, something like:

 ${__V(C_Selected_Seat_All_${__Random(1,${C_Selected_Seat_All_matchNr},)},)}

More information on JMeter Functions concept: Apache JMeter Functions - An Introduction