mardi 21 juillet 2020

Jmeter - How to use the variable set in first request for all the threads in one thread group

I would like to run one request only once, and get an authorization token from its response using Json extractor and then use that token as header in another request that runs under the same thread group.

I tried to use "setup Thread Group", but the variable value was not available to the main thread group. So, I used "If Controller" under the same thread group, with below condition:

${__groovy(ctx.getThreadNum() == 0 &&  vars.getIteration() == 1,)}

This is making the specific request to be executed only once. However, variable value is available only for one thread for the subsequent requests, but not for all the threads. Below is the picture of results tree:

enter image description here

May I know how to access the variable value set in first request for all the threads instead of just one thread?

Aucun commentaire:

Enregistrer un commentaire