I need to find text inside td and click edit in the same line, example how to find base on ID AAA02 and click edit in the same line, or any another app or automate app to do this code. Im usually use katalon-recorder for automate browser.
<table cellpadding="3" cellspacing="0" border="2">
<thead>
<tr>
<td>No</td>
<td>ID</td>
<td>NAME</td>
<td>STATUS</td>
<td>ACTION</td>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>AAA01</td>
<td>ANDRE</td>
<td>ACTIVE</td>
<td><button type="submit">EDIT</button></td>
</tr>
<tr>
<td>2</td>
<td>AAA02</td>
<td>YULIUS</td>
<td>ACTIVE</td>
<td><button type="submit">EDIT</button></td>
</tr>
</tbody>
</table>
You can use the below xpath to select the Edit
button in the row with ID
as AAA02
.
//td[position()=count(//thead//td[normalize-space(.)='ID']/preceding-sibling::td)+1][normalize-space(.)='AAA02']/ancestor::tr//button[.='EDIT']
You can find the detailed explanation on xpath here