Forum Discussion

tstmartin's avatar
tstmartin
Contributor
13 years ago

[Resolved] How to do assertion count() of multiple responses

Hi,

Is there some syntax or technique to allow comparing counts of responses of different test steps in the
XPath Match tool ?


I want to do an assertion that a count of specific elements in a test step
response matches a count of elements in a response from a previous test
step.


For example:

associateDomainsResponse == current response
insertDomains#Response == response from a previous test step

-----------------------------------------------------------
-----------------------------------------------------------
-----------------------------------------------------------
XPath Expression:

declare namespace ns2='http://v1_0.webservice.asi.proxy.example.com/';
count( //ns2:associateDomainsResponse/return/domains) =
count('${insertDomains#Response#declare namespace ns2='http://v1_0.webservice.asi.proxy.sincera.com/'; //ns2:insertDomainsResponse/return/domains}')


Expected Result:
true
-----------------------------------------------------------

Putting the count for the insertDomains response into the Expected Result area
also fails.

Perhaps I have to use XQuery or Groovy instead of the XPath Match?

Thanks

-tom

2 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    Looks like you're close, just a minor error in the second part of the expression. The count() part needs to be inside the Property Expansion instead of outside of it, like this:


    ${insertDomains#Response#declare namespace ns2='http://v1_0.webservice.asi.proxy.sincera.com/'; count(//ns2:insertDomainsResponse/return/domains)}


    Making the whole expression:

    declare namespace ns2='http://v1_0.webservice.asi.proxy.example.com/';
    count( //ns2:associateDomainsResponse/return/domains) =
    ${insertDomains#Response#declare namespace ns2='http://v1_0.webservice.asi.proxy.sincera.com/'; count(//ns2:insertDomainsResponse/return/domains)}


    Regards,
    Dain
    eviware.com