Using XPath Assertion in SOAP UI
Assertions are generally the simple and most sought validations that can be enforced in SOAP UI.
For SOAP response we have an assertion step called ‘XPath Match‘, which validates the value yielded by the specified xpath with the one provided staticly.
When we add ‘XPath Match’ assertion using the Add Assertion button, we see the below window.
There is a button called ‘Declare‘ (present in free version of SOAP UI also), it automatically declares all the namespaces of SOAP response. After declaring the namespaces using this ‘Declare’, mention the xpath of the node whose value is to be validated. Here the xpath could start from the node which comes just after the <soap:Body> node (i.e., <soap:Body> node’s immediate child). For example, if say the response xml is:
then to validate on the value of ‘Status‘ node, the xpath that should be present in XPath Expression blockalong with all the declared namespaces is
//p77:GetReportResponse/p77:GetReport/ReportResponse/Status
And, now we need to provide some expected value, inside ‘Expected Result’ block which shall validated against the corresponding node value. There is an option called ‘Select from current‘, which actually fetches the value of that xpath, from the current response. Another option called ‘Test‘, is used to test right away.
Recent Comments