I have below HTML which is having a table with 15 rows (below are the 2 rows for example)-
<table id="task" style="width:100%" class="border">
<thead>
<tr>
<th>Task </th>
<th>Request date</th>
<th>Description</th>
<th>file</th>
<th>number</th>
<th>Request</th>
<th>Tel</th>
<th>Lan</th>
<th></th></tr></thead>
<tbody>
<tr class="odd">
<td>TASK21</td>
<td><label class="readonly">25/05/2018</label></td>
<td>file</td>
<td></td>
<td>
<a href="/taskId=1&action=dispatchFromOneTaskType">123</a></td>
<td>1</td>
<td>23654</td>
<td>En</td>
<td><form id="tasksForm" method="post" action="tasks.do?action=delete" class="formulaire"><input type="hidden" name="language" value=""><input type="hidden" name="taskId" value="1"><input type="submit" value="Close"></form></td></tr>
<tr class="even">
<td>TASK45</td>
<td><label class="readonly">25/05/2018</label></td>
<td>file</td>
<td>321654</td>
<td>
<a href="s.do?taskId=&action=dispatchFromOneTaskType">753536</a></td>
<td>1</td>
<td>123456</td>
<td>En</td>
<td><form id="tasksForm" method="post" action="s.do?action=delete" class="formulaire"><input type="hidden" name="language" value=""><input type="hidden" name="taskId" value="2"><input type="submit" value="Close"></form></td></tr>
</tbody>
</table>
I want to search any row's 1st column by giving TASK number (e.g- TASK42) and then traverse to last column (9th) of that row and then click on the Button.
To do so, I am using below Xpath-
//*[text()='TASK42'][@id='tasksForm']/input[3]
Since the desired TASK can be in any of the 15 rows of the table, I can't give Relative/Absolute Xpath. Hence first searching for that TASK in any row and then traversing to the last column of that row.
But it is not working. Can you please help?