How to do assertion for dynamically changing field or tag?

I want to do a assertion for a customer contact details.. That customer has 6 contact details. That contact detail is a parent tag under that tag many child tags are there ( like adress, pH no ,landline). In some case in the parent tag some of the children tags won't be present How to validate these kind of tags?

if we are adding more contact details with at customer also it should be validated in next run.. How to do this one?

If any one knows could you please explain in detail?

Comments

  • jakubiakjakubiak Posts: 371 admin

    Could you provide an example XML that illustrates with some additional information about what you are trying to test?

  • sunil_subramaniansunil_subramanian Posts: 40

    For example
    In the First run, the XML response is populating with 3times occurance of contact details

    Particular customer has 3contact details

    Here contact details is parent tag and others are children tag


    xyz
    abc
    USA
    765432145
    12345788

    In second occurance adressline2 tag is missing
    ContactDetails>
    xyz
    USA
    765432145
    12345788

    In third occurance landline tag is missing

    ContactDetails>
    xyz
    abc
    USA
    765432145


    Whenever the children tags missing the assertion should pass..

    When ever the occurance of the parent tag is increased/decreased it should not affect the assertion validations

    Could you please help in this??

  • jakubiakjakubiak Posts: 371 admin

    Here is what you can do: for each element that may or may not be there, you can do the following:

    1. Create an occurrence assertion for the element that validates that exactly 1 occurrence is present
    2. Create a value assertion to validate the value of the element
    3. Create a conditional assertion that uses the occurrence assertion for the "if" and the value assertion for the "then"

    The result will be that the value assertion will only be run if the occurrence assertion validates that the element is actually there.

Sign In or Register to comment.