Reputation: 91
This is the response for one of my test steps:
<Names>
<NameList PropertyName="Record">
<Names>
<SimpleValue Value=" Date: MM/DD/Year "/>
<SimpleValue Value="Name: John "/>
<SimpleValue Value="Amount: 1234"/>
<SimpleValue Value="Change: 2.0 "/>
<SimpleValue Value="Total: 0.0 "/>
</Names>
</NameList>
</Names>
I'm expecting the exact match in my Xquery assertion except the value where it says total.
This is what my assertion looks like:
<Names>
<NameList PropertyName="Record">
<Names>
<SimpleValue Value=" Date: MM/DD/Year "/>
<SimpleValue Value="Name: John "/>
<SimpleValue Value="Amount: 1234"/>
<SimpleValue Value="Change: 2.0 "/>
<SimpleValue Value="Total:"*""/>
</Names>
</NameList>
</Names>
I have checked allow wildcards in my Xquery expression, but that does not seem to be working in SoapUI. Is there a workaround for it?
Note: The response order is inconsistent so cannot use Xpath. Can read the values from SimpleValue node SimpleVale[1],SimpleValue[5] but, since it's inconsistent there's no way of knowing which node contains Total.
Thanks.
Upvotes: 0
Views: 515
Reputation: 3538
If you're only interested in making sure Value="Total"
is present and you don't care what value it might have, you could use SimpleValue[contains(@Value, "Total:")]
, which just checks the attribute name. For example:
(: Replace these variables with values extracted from the soapUI response:)
declare variable $date := "MM/DD/Year";
declare variable $name := "John";
declare variable $amount := "1234";
declare variable $change := "2.0";
for $NameList in //<soapUI response payload>//NameList
let $Names := $NameList/Names
where $Names/SimpleValue[@Value = concat("Date: ", $date)] and
$Names/SimpleValue[@Value = concat("Name: ", $name)] and
$Names/SimpleValue[@Value = concat("Amount: ", $amount)] and
$Names/SimpleValue[@Value = concat("Change: ", $change)] and
$Names/SimpleValue[contains(@Value, "Total:")]
return $NameList
You would also need to strip some of those leading and trailing white space characters on the attribute values to make sure you got a good match.
Upvotes: 2
Reputation: 291
Remove the quotation marks around *. As you have it now, it'll fail because the actual value is "Total: 0.0 " but your expected value is "Total: "0.0" "
Upvotes: 0