How to use Jmeter Response/Xpath assertion For Dynamically changing elements? please explain with example.

API Response first time


API Response another time

  <Name>Tshirt</Name>          - Dynamically change
  <Price>1789.000000</Price>   - Dynamically change

1 Answer 1


Given response is different each time you will not be able to check the exact name and price of the product, however you will be able to check if:

  • response matches a certain XSD schema (contains elements which it needs to contain and doesn't contain any extra stuff, data types are matching, number and order of elements, etc. It can be done using XML Schema Assertion
  • response contains the following tags:

    • //Product/Name
    • //Product/Price

also there are numerous options like checking the number of occurrences, checking response is not null, price is above zero, etc. It can be done using XPath Assertion

Reference material:

  • price is above zero can be done using xpath assertion //Product/Price[text()>0] right ? how to write if response is not null for this example?
    – lak
    May 8, 2017 at 14:37
  • @lak using regular expression, can be chkd not null condition Oct 5, 2017 at 9:25

Your Answer

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

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