I have an error message returned for which I want to use xpath assertion to confirm. The problem is the Transaction Id changes (system generated) while the rest of the information in iongt:faultstring remains constant.
Is there a simple way of doing this assertion?
<iongt:retrieveSystemInformationFault xmlns:iongt="http://www.testing.com/xml/TestingIONGT">
<iongt:faultcode>TestError012</iongt:faultcode>
<iongt:faultstring>Transaction Id: 8781991797:
Testing error message here</iongt:faultstring>
</iongt:retrieveCustomerInformationFault>
Using an ‘*’ does not work:
<iongt:retrieveSystemInformationFault xmlns:iongt="http://www.testing.com/xml/TestingIONGT">
<iongt:faultcode>TestError012</iongt:faultcode>
<iongt:faultstring>Transaction Id: *:
Testing error message here</iongt:faultstring>
</iongt:retrieveCustomerInformationFault>
I suspect that SoapUI XPath Match Expected Result wildcards have to match entire text nodes, not part of one.
Of course, you could just assert at a less precise level, by using an asterisk for the whole text content in your Expected Result (as you mentioned this works):
But if you need to be more precise, you could also modify your XPath expression as follows. Instead of just
for example, you could have this XPath Expression:
with an Expected Result of
and another assertion with XPath expression
I’m suggesting
contains()here because XPath 1.0 doesn’t haveends-with(). If you really need to get precise, instead of justcontains(), you could substitute an equivalent forends-with()usingstring-length()andsubstring(), but I doubt that level of effort is necessary.The expected result for the above would be just
Or you could combine the two into one assert … let me know if you want to see an example of that.