XML Assertion for single element
Hi team,
I need to validate a value say itemID (used excel datasource ) from xml response but in the response xml a no. of itemID nodes gets generated ,so I have to check with each itemID present in the response.The required itemID in response doesnot everytime generates at the same node so while selecting the element I have given xpath as
/:Envelope/:Body/:Response/:itemID/text(). [/ * given]
I have used value assertion but if I have 5 RuleID in my response 1 will get validated and rest 4 will not match so the validation fails.
How to achieve this assertion ?
Kindly help.
Comments
-
Hi if anyone can help on the above
0 -
I have used the following simple custom assertion using JavaScript :
function customAssertion(input, context) {
value = context.getValue("Datasheet", "RuleID"); //Accessed from datasource
Application.showMessage("Value from data source is " + value);
Application.showMessage("Value from SOAP response is " + input.toString());
return input.toString().contains(value);
}but it is capturing all the 5 nodes' itemID passing 1 node's value because it matched with my DataSource's value and rest failed.
Even I tried to add if else statement and break but it was not working. kindly help!!
0 -
Any help ??
0 -
It sounds like you need to perform the same validation on each itemID node. If that is the case, you should be to do this by specifying an XPath that matches all itemID nodes, rather than just a specific itemID node.
1