groovy.lang.MissingPropertyException: No such property: Length for class: com.kms.katalon.core.testobject.ResponseObject

Hi everyone i am getting this error while running my API automation scripts any help would be greatly appreciated

Here’ my full codes:

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint

import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase

import static com.kms.katalon.core.testdata.TestDataFactory.findTestData

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject

import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint

import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW

import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile

import com.kms.katalon.core.model.FailureHandling as FailureHandling

import com.kms.katalon.core.testcase.TestCase as TestCase

import com.kms.katalon.core.testdata.TestData as TestData

import com.kms.katalon.core.testng.keyword.TestNGBuiltinKeywords as TestNGKW

import com.kms.katalon.core.testobject.TestObject as TestObject

import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows

import internal.GlobalVariable as GlobalVariable

import org.openqa.selenium.Keys as Keys

import com.kms.katalon.core.util.KeywordUtil

import groovy.json.JsonSlurper

‘Generate random date base from current date’

def arrive = new Date() + 30

arriveDate = arrive.format(‘yyyy-MM-dd’)

System.out.println(arriveDate)

def depart = new Date() + 32

departDate = depart.format(‘yyyy-MM-dd’)

System.out.println(departDate)

//Call dynamic offers

reqUrl = “https://xxxxxxxxxxxxx?PropertyCode=TEST&Arrive=${arriveDate}&Depart=${departDate}&Adults=2&Kids=0&Infants=0

request = findTestObject(‘Offers API/dynamicOffers’, [(‘url’) : reqUrl])

‘When’

WS.comment(“Sending GET request: ${request.getRestUrl()}”)

response = WS.sendRequest(request)

//def slurper = new groovy.json.JsonSlurper()

//def result = slurper.parseText(response.getResponseBodyContent())

//def newf = result.findAll { Map map →

//map.get(“isEligible”).contains(true) }

//println newf

def selectedIndex = 0;

def arrayResult = ;

for( int i=0; i < response.length; i++){

if(response[i].offerTemplateCode == ‘memberOffer’){

arrayResult[0] = response[i].offerItemId

arrayResult[1] = response[i].serviceCollectionId

println arrayResult[1]

break;

}

else{

println arrayResult[1]

}

}

below are the errors from console

2024-06-05 06:33:21.529 DEBUG testcase.test - 13: for ([i = 0, i < Length, (i++)])
2024-06-05 06:33:21.563 ERROR c.k.katalon.core.main.TestCaseExecutor - :x: Test Cases/Offers API/test FAILED.
Reason:
groovy.lang.MissingPropertyException: No such property: Length for class: com.kms.katalon.core.testobject.ResponseObject
at test.run(test:48)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:448)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:439)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:418)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:410)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:285)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:137)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:128)
at TempTestCase1717540393602.run(TempTestCase1717540393602.groovy:25)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

2024-06-05 06:33:21.576 ERROR c.k.katalon.core.main.TestCaseExecutor - :x: Test Cases/Offers API/test FAILED.
Reason:
groovy.lang.MissingPropertyException: No such property: Length for class: com.kms.katalon.core.testobject.ResponseObject
at test.run(test:48)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:448)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:439)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:418)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:410)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:285)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:137)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:128)
at TempTestCase1717540393602.run(TempTestCase1717540393602.groovy:25)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

1 Like

Hi there,

Thank you very much for your topic. Please note that it may take a little while before a member of our community or from Katalon team responds to you.

Thanks!

Hi @dptest00123,

Welcome to our community. I found a discussion about this error here, please take a look!