Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

which assertion can be used to check value of element is present from the list.

Options
divyang
divyang Posts: 8

how do I check if a value is available from the list. for an example I want to verify a value NJ for element "state" is present in ( NJ, NY, PA, CA). I tried JSON Assertor --> String Comparison Assertion with "Element must contain" - "Expected value NJ,NY,PA,CA which did not work.

Tagged:

Comments

  • benken_parasoft
    benken_parasoft Posts: 1,230 ✭✭✭
    edited September 2018
    Options

    Are you saying your JSON looks like this?

    [
      "NJ",
      "NY",
      "PA",
      "CA"
    ]
    

    There's more than one way of performing a validation like that. One way is to use "Occurence Assertion" with XPath like /root/item[text()="NJ"] with expected number of occurences == 1 (or >= 1, depending on what you want to check).

Tagged