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
-
Could you provide an example XML that illustrates with some additional information about what you are trying to test?
0 -
For example
In the First run, the XML response is populating with 3times occurance of contact detailsParticular customer has 3contact details
Here contact details is parent tag and others are children tag
xyz
abc
USA
765432145
12345788In second occurance adressline2 tag is missing
ContactDetails>
xyz
USA
765432145
12345788In 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??
0 -
Here is what you can do: for each element that may or may not be there, you can do the following:
- Create an occurrence assertion for the element that validates that exactly 1 occurrence is present
- Create a value assertion to validate the value of the element
- 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.
0