jmeter

Passing an extracted json variable in jmeter into a 'Random Variable' as an integer


I did a JSON extraction. The returned value is a '26' but it appears to be stored as a string.

When I pass it into the 'Random Variable' in the Maximum Value field it is not accepted. I think I need to convert it to a string, but I am sure of the most efficient way to do this

Any suggestions?


Solution

  • "Converting" the variable doesn't help, 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)
    

    Being a "Configuration Element" Random Variable is executed before any Post-Processor, so you won't be able to use the variable from the Post-Processor there.

    So consider using __Random() function for generating a random value, you might need to use in in combination with __V() function if you want to refer another variable.

    Functions are being evaluated where they're met in the test plan hence they don't obey the execution order. See Apache JMeter Functions - An Introduction article for more details.