0

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 requests Commented Sep 5, 2017 at 13:41

1 Answer 1

0

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"
Sign up to request clarification or add additional context in comments.

3 Comments

Hey @Dmitri T, I added a New pictures, the problem is in the assertion as you mentioned, I created a new variable and compare it to user define variable. it is called cid99 and I compared it to the expected cid. from the debug sampler you can see that they have the same value, but the assertion still failed ( if it is like the left pic you uploaded), I do not understand way, since only one Http request is enabled and the others are disabled, Way it failed? the second solution is to duplicate 50 steps for each Http, can you please advise what I am doing wrong?
Your cid99 variable is not defined
sorry but still I do not understand, how to define this variable, the only way that I know is to user define variable, but this is not a user defined this is Jmeter, can you be more specific.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.