I was able to achieve this using parent nad following-sibling… I was struggling because I was using something like forward-sibling
//*[@id="tab_contrato"]/div/table/tbody/tr/td[2]/label[@class="hint"][not(contains(@data-hint, "CARTÃO RMC"))]//parent::td/following-sibling::td[1]
A shorter XPath would be :
//table//label[.="RMC"]/following::td[1]
Output : 318 – BANCO BMG
I need to get the <td> 318 - BANCO BMG </td>
from the next to last line of the code. It dynamically changes from client to client but the <label class="hint" data-hint="CARTÃO RMC">RMC</label>
or fa fa-credit-card
will always be there.
I’m new programming and now I’m struggling with this html to get the right xpath. Already read about “advanced” xpaths and get most of them when I need, but can’t deal with this one.
<tbody>
<tr class="">
<td>
<center><i class="fa fa-dollar-sign" aria-hidden="true" style="color:#11b336;"></i></center>
</td>
<td>
<label class="hint" data-hint="EMPRÉSTIMO CONSIGNADO">CONSIGNAÇÃO</label>
</td>
<td>
341 - ITAU
</td>
<tr class="">
<td>
<center><i class="fa fa-dollar-sign" aria-hidden="true" style="color:#11b336;"></i></center>
</td>
<td>
<label class="hint" data-hint="EMPRÉSTIMO CONSIGNADO">CONSIGNAÇÃO</label>
</td>
<td>
707 - DAYCOVAL
</td>
<tr class="">
<td>
<center><i class="fa fa-credit-card" aria-hidden="true" style="color:#3f88b5;"></i></center>
</td>
<td>
<label class="hint" data-hint="CARTÃO RMC">RMC</label>
</td>
<td>
318 - BANCO BMG
</td>