Question

I have the following request in JMeter in XML which looks as follows:

<gml:lowerCorner>13.84 6.3677</gml:lowerCorner>
<gml:upperCorner>64.9404 17.8612</gml:upperCorner>

How do I edit these values so that each time they are randomly generated? I am hoping to achieve this in Java but also considering Javascript. Any help would be much appreciated.

Was it helpful?

Solution

I would suggest using JMeter Functions instead. It looks like that _Random() or _RandomString() could be a good choice.

Something like

<gml:lowerCorner>${__Random(0,99,)}.${__Random(0,99,)} ${__Random(0,9,)}.${__Random(1111,9999,)}</gml:lowerCorner>

Should do the trick for you.

It isn't recommended to use Beanshell for heavy scripting. For something once-only or very light like reading configuration file, appending something to the log, etc. it's fine, but several calls to obtain a random number can have negative impact on your test performance. If you need to go down to Java code I'd suggest using JSR223 Sampler (or Pre Processor) and Groovy as language as it provides performance comparative to native Java code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top