0
votes

I have a question about Jmeter's regex and Json extractor. I sent Http request and parsed the response, I see that the only way it worked is if the json extractor and regex are inside the Http request section.

The problem is that I want to create generic framework, so the user can disable some requests and enable another, thus if I need to put the json extractor in each request I will duplicate the parsing for each request individually, instead of one to all (remember only one at a time will be active). Marked in Yellow the working scenario, and unmarked the expected scenario with only one parse. the actual results is that I get null in the json extractor and regex

Can someone explain if this is the only way?

After investigating I saw that the problem is with the assertion, the assertion not cope with situation that it is out of the Http request, it say that the response is null while I saw that the variable is not null.

Provided Pic for this issue enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

1
Normally different request return different responses, no? if not you can make your HTTP request generic with using a variable in Path as ${path} and loop with different requestsuser7294900

1 Answers

0
votes

JMeter Post Processors (including Regular Expression Extractor, JSON Extractor, whatever) are following Scoping Rules, like:

  • If you put a Post Processor to be a child of a certain sampler - it will be applied to this sampler only
  • If you put a Post Processor at the same level as samplers - it will be applied to all samplers which are on the same level with it

See The Scope of JMeter Assertions chapter of the How to Use JMeter Assertions in Three Easy Steps guide for more details, here is the visual representation:

JMeter Assertions Scope

Remember 2 things:

  • Post Processors have their cost so go for extending their scope only if each sampler produces the cid you're looking for, otherwise it will create an overhead and increase resources consumption
  • if a certain sampler won't have this cid value it will either become null or will have a default value so your test can become more "fragile"