xpathdomxpath

How to select specifix ID`s in table for P4 column via XPath


I need to choose ID`s from table with Priority P4. Added code from page with example the first row from table.

enter image description here I have created XPath for specific colums but can't create XPath for solution: "choose ID in table if Priority = P4".

My locators:

<table _ngcontent-c17="" class="ticket-table table table-striped table-responsive">
                         <tbody _ngcontent-c17="" style="overflow-y: initial !important;">
                             <!----><tr _ngcontent-c17="">
                                 <td _ngcontent-c17="" style="width: 50px;">
                                     <div _ngcontent-c17="" class="checkbox-radios checkbox">
                                         <label _ngcontent-c17="">
                                             <input _ngcontent-c17="" id="tickets-block-select-ticket" name="selectTicket" type="checkbox" value="2062"><span class="checkbox-material"><span class="check"></span></span>
                                         </label>
                                     </div>
                                 </td>
                                 <!---->
                                 <!----><td _ngcontent-c17="" style="width: 5% !important;">
                                         INN-22
                                 </td>
                                 <td _ngcontent-c17="" style="text-align: left; width: 20%;">
                                     <a _ngcontent-c17="" class="locked-link" id="ticket-block-title" title="Title: Create weekly report 
                                         Description: " href="#/ticket/2062">
                                         <!---->
                                         <!----><span _ngcontent-c17="">[Inner] </span>
                                         <!---->
                                         Create weekly report
                                     </a>
                                 </td>
                                 <td _ngcontent-c17="">
                                     
                                 </td>
                                 <td _ngcontent-c17="">
                                     P4
                                 </td>
                                
      </tbody>
                </table>

Solution

  • Try this XPath-1.0 expression:

    //tr[td[contains(.,'P4')]]/td/a/@id
    

    Result is the id attribute of the <a> child:

    ticket-block-title