Forum Discussion

gtf0utc's avatar
gtf0utc
New Contributor
13 years ago

Do I understand the XPath Match assertions correctly?

Hi all,

I'm just hoping to confirm my interpretation of what is happening in this situation (it's one thing for me to suspect that it works this way, but since I'm using it for testing, I have to know...).

I have an XPath Match assertion like this (skipping namespaces):
//ns1:Response[1]/ns1:Result[1]/a:MessageText[1]/*/text()

and an expected result of:
${DataSource#Message}


What I believe is happening is that the star (*) is allowing a match on the text of any of the child elements of a:MessageText[1] (which is an array of <b:string>s). So, for instance, a result including
            <a:MessageText xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<b:string>Message 1</b:string>
<b:string>Message 2</b:string>
<b:string>Message 3</b:string>
</a:MessageText>


would return a true assertion if my ${DataSource#Message} was 'Message 1', 'Message 2', or 'Message 3'.

Can anyone please confirm that I'm correct in my understanding?

Many thanks!

gtf
  • gtf0utc's avatar
    gtf0utc
    New Contributor
    I know that what I'm describing isn't the way XPath would normally work - this is just what I'm seeing in SoapUI's behavior. It appears to be a slightly non-standard implementation. That's what I'm trying to confirm.
  • SiKing's avatar
    SiKing
    Community Expert
    From personal observation I believe SoapUI (not XPath) will match on any found text at that XPath level.
    So in your example, the * replaces any one element at that level of hierarchy - normal XPath behaviour. SoapUI would return a true assertion if your ${DataSource#Message} was any one of 'Message 1', 'Message 2', or 'Message 3'.
    HTH.