Returning the XPath value of a certain TestObject dynamically


Hi all,
I was wondering if there’s any way to return the xpath of a certain object dynamically based on parameters injection.
To have an environmental knowledge, I’m trying to check one by one all the checkbox of a grid, to do so I’m iterating over the checkbox shown in the actual grid page, but it seems like I’m not passing correctly the counter parameter and any value I submit will always and only check the first checkbox in the box skipping the rest. Since for some reason I couldn’t find a way to get out of this, I simply wanted to print the actual value of the xpath after my parameter injection to see what was going on.

P.S.: I’ve noticed that Katalon owe two types of XPath. It owes it as an attribute and as a separated entity. I’m currently using the separated entity one. I don’t even really know if there’s any difference between them, if someone is willing to explain I would appreciate it :slight_smile: Thank you


Yes you can do this, I would loop through. Can you share your xpath and I’ll give you an example to help?

Some examples of how I would handle this would be to create a custom method to create the object:

	public static Object getObjectGridStuff(int countHere) {
		TestObject objectGrid = new TestObject("objectName")
		objectGrid[countHere].addProperty("xpath", ConditionType.EQUALS, '//*/table[@id="grid"]/tbody/tr/td[countHere]')
		return objectGrid;

Then something like this:

int gridCount = 10

for (int i = 1; i <= gridCount; i++) {
		gridObject + i = getObjectGridStuff(i)
		WebUI.verifyElementPresent(gridObject + 1, 0, FailureHandling.CONTINUE_ON_FAILURE)

I imagine something like this would work. You are creating the object dynamically, you just have to specify the xpath and the number of objects. Its not perfect but might work for what you are going for.


this is an example of some dynamic xpaths I worked with someone else on. If this helps:


My dynamic xpath was the following>

I found out that I was experiencing troubles because previously I was using this one:

//div[@class=‘modal-footer’]/div/span[$i]/span[text()=’$selectedItem’] without the { } on the parameters passed.

Along with this, I came out with another point.

I’ve got this XPath:

//tr/td/div/label/input[contains(@class, ‘ng-empty’)]

Is there a way I can use an xpath expression to return the amount of input tags which are not empty?
I’ve found out the following on the internet, but couldn’t manage to make it work out properly because I don’t know how to translate that string into an xpath expression:

count(/tr/td/div/label/input[contains(@class, ‘ng-not-empty’)])


hmmmm that I am not sure of… maybe something along these lines?