<table>
<tbody>
<tr>
<th style="width:200px;">Features</th>
<th style="width:300px;">Settings for this entry round</th>
<th style="width:300px;">
</tr>
<tr>
<td style="background-color: rgb(234, 234, 234);"> is_team_round </td>
<td style="text-align:center;">
<div>
<select id="account_3" onchange="changeAccount(3);" style="background-color: rgb(255, 255, 255);">
<div> </div>
</div>
</td>
<td style="text-align:center;"> Yes </td>
</tr>
<tr>
<td> is_file_uploads </td>
<td style="text-align:center;">
<div>
<select id="account_4" onchange="changeAccount(4);">
<div> </div>
</div>
</td>
<td style="text-align:center;"> Yes </td>
</tr>
</tbody>
</table>
How can I select the ID account 3 depending if the text is is_team_round?
I tried //td[contains(text(), 'is_team_round')], and it selects is_team_round.
Then I tried //td[contains(text(), 'is_team_round')]//select[@id='account_3'], but it doesn’t work
Try the xpath:
This says to find the row (tr) that has the cell (td) with text ‘is_team_round”. Then find the select list inside that row.
Note: Your original solution did not work because it tried to find a select list inside the cell containing the text. As seen in the HTML, the select list is not inside the same cell. Hence, the need to use a common ancestor (ie the row).