When calling an API the response consists of a collection of Transactions. Each collection consists of 4 elements (Balance, Transaction Date, Type, and Amount)
[
{
“balance”: “404.01”,
“transactionDate”: “2020-02-19”,
“type”: “WITHDRAWAL”,
“amount”: “-40”
},
{
“balance”: “444.01”,
“transactionDate”: “2020-02-19”,
“type”: “WITHDRAWAL”,
“amount”: “-55.99”
}
]
Using JSONPathFinder I can see that each collection is assigned a “position”, for example the first is set consists of [0].balance, [0].transactionDate, [0].type, and [0].amount
I need to loop thru the returned response collection and then verify each element in each set.
I attempted to use the Web services keyword of getElementCount to determine the outer loop count but got an error on the call after I set it up
def slurper = new groovy.json.JsonSlurper()
def responseObj = slurper.parseText(requestObj.getResponseBodyContent())
TransCount = WS.getElementsCount(responseObj, null)
This is the error received
groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords.getElementsCount() is applicable for argument types: (java.util.ArrayList, null) values: [[[amount:-40, balance:404.01, transactionDate:2020-02-19, type:WITHDRAWAL], …], …]
Possible solutions: getElementsCount(com.kms.katalon.core.testobject.ResponseObject, java.lang.String), getElementsCount(com.kms.katalon.core.testobject.ResponseObject, java.lang.String, com.kms.katalon.core.model.FailureHandling)
There doesn’t seem to be any Help info on this call that I could find…has anyone successfully used this in setting up a loop?