Forum Discussion

raptor's avatar
Occasional Contributor
7 years ago

count( //ns1:Response/ns1:photos/ns1:photo/ns1:e)

I am using the SOAPUI tutorial to learn SOAPUI using the Flickr API.


But one of the assertions in the Interestingness Request test step is failing. The assertion is an Xpath match which should match the count to 100


Declaration of xpath expression is as below, which should match expected result of 100.

declare namespace ns1='';
count( //ns1:Response/ns1:photos/ns1:photo/ns1:e)


I see that there are 100 nodes of "photo"

Why is it failing and how do I fix it? 

7 Replies

  • avidCoder's avatar
    Super Contributor

    Is this how your xml response looks like?


                <ns2:Name>Parent 1</ns2:Name>
                <ns3:Child>Child 1</ns3:Child>


    This will it is showing 100 times.. Right?
    Then you should use this code :- count(//ns1:Response/ns1:photos)

  • JHunt's avatar
    Community Hero

    You should be able to see why it's failing, e.g.


    XPathContains comparison failed for path [declare namespace ns1='http://localhost/me'; count(/ns1:Response)], expecting [100], actual was [1].


    Post your failure and we can help you work out why. See if you can attach the full response for us as well.


    It could just be that the response doesn't necessarily have 100 photos. The tutorial you linked specifically says:


    • Interestingness Request - gets the current list of Interestingness at flickr in JSON format and validates the response to contain 100 entries (which it actually won’t always do)
      • nmrao's avatar
        Champion Level 3

        Based on the attachment which is json, here is the Script Assertion:


        //Check if there is response
        assert context.response, 'Response is empty or null'
        def json = new groovy.json.JsonSlurper().parseText(context.response)
        def actualPhotos =
        //log the photo instances actualPhotos
        def expectedPhotos = 100
        assert expectedPhotos == actualPhotos



  • JHunt's avatar
    Community Hero


    Aah, it's only 99.