Konzy262
Konzy262

Reputation: 3117

How do I use regular expression/JSON path extracted variables within other variables in JMeter?

I'm attempting to use a variable that was previously set either via a 'Regular Expression Extractor' or a 'JSON Path Extractor' in a 'User Defined Variables' node in JMeter.

I can't for the life of me figure out why it's not working.

This is my extractor....

enter image description here

And this is my user defined variables node attempting to use the variable from the extractor....

enter image description here

I don't think it matters where it is, as variable scope apparently is at thread level, but I've tried this node both immediately after the regex extractor and in a different future request.

When I attach a debug post processor, these are the results that are returned...

signin=a5360708f46ddea1c8491889bb4433d7
signin1=${signin}
signin2=${__V(${signin})}
signin3=${__eval(${signin})}
signin4=${__evalVar(signin)}

${signin} has clearly been set correctly evidenced by the string value, however none of my substitution attempts have worked.

What am I doing wrong here?

Thanks,

Upvotes: 1

Views: 473

Answers (2)

Ori Marko
Ori Marko

Reputation: 58872

Adding to @UBIK LOAD PACK answer,

User Defined Variables set variable at start of the test before Samplers are execute and therefore before signin variable is been assign.

Note that all the UDV elements in a test plan - no matter where they are - are processed at the start.

You should add variables assignment in User Parameters which will be the child of a sampler after the sampler you assign signin,

Noice that if you don't have Sampler after you can add Test Action (with pause 0 ms ) or Debug Sampler which won't effect your test and enable you to set variable using signid updated value.

Upvotes: 1

UBIK LOAD PACK
UBIK LOAD PACK

Reputation: 34566

This is due to the fact that User Defined Variables is not updated after the variable is filled in.

So you need to use a User Parameters that you will put as a child of the first Sampler following the sampler that contains the Regex Post Processor.

Upvotes: 1

Related Questions