Find parent of the element

We are having a list structure where I need find a position of the text in a list and click it’s parent object. Can any body help us to resolve that. Please see below example

<table id="myid">
 <tr>
  <td>1st text</td>
 </tr>
 <tr>
  <td>find me</td>
 </tr>
 <tr>
  <td>3rd text</td>
 </tr>
</table>

I need to find on which position “Find Me” Text is present, i.e second and first of the table

The CSS path for the TD containing “find me” is:

#myid tr:nth-child(2) > td

I need find a position of the text in a list and click it’s parent object.

Following xpath expression should work:

 //td[text()='find me']/parent::tr

Note that I used ‘parent axes’ of xpath (https://www.w3schools.com/xml/xpath_axes.asp).

2 Likes

@4280-kazurayam thanks for reply, This one works for me. Marking this topic as done.