4

XPath extractor response assertion passed first run but in second run it is getting failed because <name>pc</name> is not coming in API. How to skip this element if it is not coming in second run without failing response assertion or any suggestions for this?

API response first run:

enter image description here

API response in second run: missing element < name > pc < /name >

enter image description here

enter image description here

Response assertion - DB values(name_1)using jdbc request match with xml element(name) in API response

enter image description here

1
  • How are first and 2nd (following) samplers defined? Is it the same thread for instance? Or just the 2nd and subsequent call or...?
    – Ray Oei
    Dec 1, 2017 at 15:05

3 Answers 3

0

You have two ways:

  • either you add an If Controller checking the content of the name in the response (clause be like ${__groovy( ${name}?.trim() )} ) and put inside there the assertion, so to avoid asserting if the name is empti

  • or you try to make it pass even if the name is empty: you need to figure out why the API is returning an empty name; in that case your comparing value (expected value) should be empty as well; you cannot have the test pass if an expected information is not returned

0

I would suggest you to use /part01[position()<2] as a value of XPath query. I think it will solve your problem.

XPath Extractor

0

use JSR223 Assertion for assertion. So, you'll have better control over it.

String responseData = vars.get("name");

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.