Solution 1 :

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]

Solution 2 :

A shorter XPath would be :

//table//label[.="RMC"]/following::td[1]

Output : 318 – BANCO BMG

Problem :

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>

Comments

Comment posted by Gilles Quenot

What have you tried so far ?

Comment posted by Moisa

With

Comment posted by Moisa

Could you help me?

By