Ido Barash
Ido Barash

Reputation: 5142

JMeter http choose different url variable

I want to test a resource that gets a token in the URL. for example: localhost:8080/api/{TOKEN}/function

I want JMeter to choose from a list of 4 different tokens. is it possible?

Upvotes: 0

Views: 668

Answers (1)

Dmitri T
Dmitri T

Reputation: 168197

Everything is possible given JMeter is open source.

If you have i.e. 4 User Defined Variables containing tokens like:

User Defined Variables

You can get a random one for the each request using __V() and __Random() functions combination like:

${__V(TOKEN_${__Random(1,4,)})}

Random Variable demo

So you can change "Path" of the HTTP Request Sampler to look like:

/api/${__V(TOKEN_${__Random(1,4,)})}/function

and that should be it. See Here’s What to Do to Combine Multiple JMeter Variables article for more details.

Upvotes: 1

Related Questions