Ask a Question

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

tstmartin
Contributor

[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 2
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

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
tstmartin
Contributor

Excellent!
Does exactly what I needed!

Thanks Dain!
cancel
Showing results for 
Search instead for 
Did you mean: