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.

Assertion to be added to check a value present in one of the two xpaths

api_tester
api_tester Posts: 28

Hi All,

If I want to add an assertion for a value but it can be present in one of the two xpaths of the response so I was thinking of adding OR assertion of the Compound assertion but it is getting failed.

eg : I want to fetch an amount and the value can be either in buyer tag or seller tag.So I have added value assertion for the xpath having buyer tag and then again another for seller tag then I have added OR assertor and grouped the above value assertion. But the thing is if the amount is present in the buyer tag it will get validated but as we have given OR assertor it will get failed because Seller does not have that amount. So I was thinking of IF ELSE assertor but it is not present. What can be alternative solution ??

NOTE: Both the buyer and seller tags are generated in the response but we need to check if one of the either tags has that amount value mentioned in the Datasource excel .

Comments

  • jakubiak
    jakubiak Posts: 813 admin

    I configured an assertor using an OR assertor with two value assertions, and it works for me. The assertor passes even if one of the elements has the wrong value or is not present at all. If you still cannot get it to work, perhaps you could contact Parasoft support for help.

  • api_tester
    api_tester Posts: 28

    Thanks Jakubiak. I have again created a new .tst and followed the steps of adding assertion, now it is working . :)