SoapUI XPath assertion - wildcard string with Excel dataSource

812 Views Asked by At

I want to use an assertion "expected result" that uses both some form of "contains" function or wildcard AND gets the text to test against from an Excel dataSource. The SoapUI 'contains' function has no way to use a dataSource that I've found, and I cannot figure out how to use an XPath function like contains with a dataSource. Can someone please explain how that works?

--

I've been asked for more detail.

In SoapUI, if I add an assertion and choose the request/response as the source, I then have a choice of assertions. One of them is "XPath Match". I can use that to designate a specific field in the response, in this case, which value I want to test.

Having chosen the "XPath expression" in the top half of the "XPath Match Configuration", I can then choose my Excel dataSource as the content for the lower half "Expected Result". I have used this to test an error code against an error code from the Excel spreadsheet.

What I don't know how to do is determine, in this assertion, that the error message returned contains the value in Excel. I figure something special goes into "Expected Result" in the "XPath Match Configuration" box, but I don't know what.

XPath Match Dialog

1

There are 1 best solutions below

0
On BEST ANSWER

The Expected Result of the XPath assertion is only a "dumb" string. The best that you can do in this field is property expansion ... which does not help your cause.

Instead you will need to use the top portion, where you can enter XPath Expression, that provides the logic you are looking for. Your XPath expression will need to look something like:

contains(//*:some/*:node, '${data_source#property}')

and your Expected Value will be simply:

true

Convenient reference, in case you need it.