How to find the row number of a cell in a table

I am hoping someone can help me with this. I have a table which has two columns and can be any number of rows.

the table items are:
column 1 existing records
column 2: buttons to edit, delete, duplicate and other actions on the record in row 1

i have figured out how to locate the element in the table by using an xpath locator with a parameter that contains the text of the item i am looking for.
however locating that element only gives me the element in column 1, which cannot be actioned.

what i need to do once I locate my element, is find out what row it is on, so I can use the row number as a parameter to then click on the buttons to the right and be able to edit the item.

i think i can figure out how to identify the individual buttons in the column 2 cell, but i dont know how to find the row number i am on.

so basically i am identifying my xpath as:

[foundElement] //td[. = ‘{parameterContainingItemNameIWantToEdit}’]
which gives me an object that can be found and highlighted with the ‘find element’ magnifying glass.

how can i 'get [foundElement]‘s RowNumber’? i cant find any actions to do this for me?

1 Like

You already know that there are 2 columns, so the only thing left is to count the rows,
It can be done with the action count elements:
I’ve changed the xpath to find all the rows in this table by removing [1]

Now I will use this step:

and multiple by 2:




I set columns to 2 manually but you can also count them if you have unlimited columns/rows.

Do you need the row number? How about using xpath sibling? Something like //td[. = ‘{parameterContainingItemNameIWantToEdit}’]/following-sibling::td

If you can do that, I think you’re one step closer to click on the edit item.

Reference material (read about Following Sibling): XPath Axes: Ancestor, Following Sibling, Preceding - Scientech Easy