How to get text from specific column and row in table
I used this document to go through my webpage, there are several tables on my page and when I tried to find the specific table I tried to change
WebElement Table = driver.findElement(By.xpath("//table/tbody"))
WebElement Table = driver.findElement("dtgDetails"))
to find the specific table i needed on my page but this did not work.

I let the boilerplate code run until it found the piece in the table that I need and from however it maps the tables I found that the info I need is Row 141 and Column 5.

Is there a way that I can just say find Table getText from row 141 and column 5 ?

Tables are represented by HTML elements, just like buttons, dropdowns, menus, etc., are also HTML elements. Because HTML is code written by people, and every person has a unique way of writing code, there’s no way to implement something like findTable() or getText(row x, column y) that will be a “one size fits all” solution.

That’s why Katalon (and the underlying Selenium) can’t offer a clickButton() method or a getCellText() method. Instead, the more generic click() and getText() methods exist, and you as the programmer must tell these methods which elements to perform the work on.

If you can share the HTML for the table you are working with, I can work with you on a way to get the text you want from your (probably custom/unique) table.

(I wanted to get rid of some information, like the town but otherwise these are not real addresses)

I am looking for the tracking number which is the really long circled number. If I inspect this page the 4 entries make up one table with id = dtgDetails and then every value is one table as well

and the HTML looks like this so class="resultsTable"is one row of the big table and I want to find the headerPIC3 under the class="resultsNumbering">1
the tracking number is td class='headerPIC3' but the thing that confuses me is that every one of the tracking numbers is under the class headerPIC3 and the actual value is outside.

I know this is kind of messy, ideally I would like to be able to hover over the source code and highlight the piece I am looking for to show you but I do not know how to do that and use the snipping tool at the same time. Please let me know if I need to provide more information. Thank you very much for your help.

Wow, nested tables, everyone’s favorite :sweat_smile: This pretty much proves the point in my original response. There’s no way to handle this in a generic way that would work for everyone, so lets work on a custom solution.

I’ll suggest just a solution to get the tracking number for a given row, as identifying a row won’t be too hard, and finding any element within a row is relatively straight forward. But your idea of row AND column gets tricky with nested tables, because there’s no clear definition of what a column is with that setup.

The heart of the solution is going to be your locator. I can suggest an xpath, but I’d like to do it in pieces and you can tell me if they make sense:

1.) Locate the “results table”:


That should identify this piece:

2.) Within the “results table”, locate the appropriate row:


This should identify (depending on the value you’ll provide for “rowIndex”) these:

3.) Within the appropriate row, locate the tracking number:


Which should locate the actual numbers, as long as there’s one (and only one) td[@class=‘headerPIC3’] element per row.

4.) Create a test object with that xpath, then call it in your script:

def rowIndex = 1 // this will grab the tracking number for the first row
def trackingNumber = WebUI.getText(findTestObject('path/to/test/object', ['rowIndex' : rowIndex]))

If this works for you, you could create similar test objects for the other elements in the table that you might want to retrieve the text for (Recipient Address, etc.). Give this a try, and let me know if you need anything clarified :slight_smile:


Hi, I have just gotten to work and I am back looking at the test case!!

The thing I am most confused with is creating the object, //table[@class='ResultsTable']/tbody/tr{$rowIndex}]/td[@class='headerPIC3']/a
this path is supposed to be in the ‘Selected Locator’ box and the ‘Selection Method’ should be ‘xPath’, I know for other objects I have needed to find and have spied on Katalon maps then and uses objects that are nearby under ‘Object’s Xpaths’…(right?) so is there anything I am missing in creating this object?? I tried the fix but I think I might be missing something because it still is not working.

I also am kind of confused because when I run this I see that the test errored but I do not see a console so I do not see the error…

Thank you so much for your help and patience!

Your test object should look like this:

Please ensure the following:
1.) Selection Method = “Attributes”
2.) Add an Object Property with Name = “xpath” and value = “//table[@class=‘ResultsTable’]/tbody/tr{$rowIndex}]/td[@class=‘headerPIC3’]/a”
3.) Make sure the “Detect object by?” checkbox is selected for the xpath.

1 Like

I am still just having trouble locating the object, everything I have tried comes back with ‘object does not exist’. :cry:

I tried to spy on the tracking number but that did not work.

I tried another test with this object and this is the error


Go back over your code, very carefully. A simple typo crept in somewhere…

You want…


not {$rowIndex}

1 Like

Oh boy, :sweat_smile:

Thank you so so so much for all your help! Got it!!!

1 Like

Hi krista,

We’re you able to get the text as expected? It looks like the errors you were sharing were an issue locating your custom test object in the object repository (nothing to do with finding the element on the page itself, this is a separate error altogether).