Can i Parameterizeda only part of Test Object id?


i have a bunch of elements with the same id, that only changes by a number at the end of the id, like this:
the xpath of the items is: id(“dashboard-device-name-0”)

i want to iterate through all these items without creating multiple test objects.
i read this:
the solution there isn’t good for my case, i tried it it doesn’t work.

any idea how to attach this problem?


Hi Udi,

try this:

// define your max ID
int maxAvailableId = 10

// in each iteration, create a new test object with _i_ ID and do whatever you want
// if your id starts from 1, change for loop definition accordingly
for(int i = 0; i <= maxAvailableId; i++) {
    TestObject to = new TestObject()
    to.addProperty('xpath', ConditionType.EQUALS, 'id("dashboard-device-name-' + i + '")') // or any other action

sounds like exactly what i need!

Sadly it doesn’t work for me, probabaly something i’m missing(maybe an import? i tried ctrl + space and got nothing), here is the error i get:
Test Cases/Verify Backup Status FAILED because (of) Variable ‘ConditionType’ is not defined for test case.

i was missing this:
import com.kms.katalon.core.testobject.ConditionType

after adding this the code works fine!
Thank You!