I believe this XPath should accomplish what you want to achieve.
//tbody[@id='defaultOverviewTable_data']/tr[./td[2][text()='HemaSundar']]//button[@alt='Edit']
Note:
td[2] is used because XPaths are 1 based, and you're looking in the second column
You mention clicking the button where
title="Edit"
but your code snippet doesn't actually have that so I'm selecting byalt
attribute instead
XPaths can be very powerful, let me know if you'd like a more in depth explanation
EDIT: Adding better explanation of XPath below...
//tbody[@id='defaultOverviewTable_data']
This finds the tbody element with the id='defaultOverviewTable_data', anywhere on the page. Simple
/tr[./td[2][text()='HemaSundar']]
This finds a tr
element that is an immediate child of the tbody
(there is only one /
at the beginning). The square bracket part means that it will only find rows that match the criteria within the square bracket (./td[2][text()='HemaSundar']
), or in english, it will only find rows that have the text 'HemaSundar' in the second child td
.
//button[@alt='Edit']
Finally, this will find any buttons below the tr (not just immediate children, because of the double //
), that have an alt
attribute of 'Title'. You can switch up the @alt part to match any other attributes if you wish.
Don't forget to mark this answer as correct if it's solved your issue :)