Reputation: 398
is there is way to check the count of the items returned. basically I have a soap service which can return list of data items, is there an easy way to have an assert statement to check the count of the list? tried groovy script but didn't have much luck
Upvotes: 1
Views: 14462
Reputation: 745
Yes. You can create a XPath Match assertion. Use the count() function.
There is a website that is a nice reference for all the XPath functions: http://zvon.org/comp/r/ref-XPath_2.html#Functions~count
Upvotes: 1
Reputation: 18507
You can add and assertion of XPath Match type in your testStep, and there check the condition. i.e you have a response similar to:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<myRoot xmlns:nt="http://mynamespace/">
<list>
<element>data1</element>
<element>data2</element>
<element>data3</element>
</list>
</myRoot>
</soapenv:Body>
</soapenv:Envelope>
Then add in your assertion the next XPath count(//*:myRoot/*:list/*:element)
and set the expected result, in this case 3
:
Hope this helps,
Upvotes: 5