0

When I right click and select inspect element, The element I want to find on the web page has this code:

<input type="text" ng-if="!editing" ng-model="item.Price" ng-click="inputFocus()" ts="" required="" placeholder="قیمت :" class="ng-pristine ng-untouched ng-scope ng-empty ng-invalid ng-invalid-required">

There are other elements with same code, and same xpaths on the page too, and the elements don't have specific id attribute. So how can I find the specific elements that I want when they have same codes?

EDIT: One of the element's HTML code:

<fieldset class="fieldset ui-state-default ng-scope" id="227" ng-repeat="item in $root.selectedMarketWatch" ng-class="{ fullWidth:$root.uiSettings.fullWidthTable || item.showMaxSize || openLeft }" ng-hide="item.Hide">
  <legend class="legend Saffron" style="cursor: move"><span class="title ng-binding">SAFTR98    -</span><span class="title ng-binding">قرارداد آتی زعفران نگین تحویل تیر ماه 1398                                                          </span><span class="Font Ico-info-circle sub-menu" ng-click="showSubMenu=!showSubMenu"></span>
    <i
      class="Font Ico-times" ng-click="$root.hideContract(item)"></i><i class="Font Ico-window-maximize" ng-click="fullSizeContract(item)"></i><i class="Font Ico-window-minimize" ng-click="minimizeContract(item)"></i>
      <ul class="menu-detail" ng-class="{ show:showSubMenu }">
        <li class="menu-detail-li"> سر رسید: <span class="list ng-binding">1398/04/25</span></li>
        <li class="menu-detail-li"> روز گواهی: <span class="list ng-binding">1398/04/25</span></li>
        <li class="menu-detail-li"> وجه تضمین: <span class="list ng-binding">5,000,000</span></li>
        <li class="menu-detail-li"> حداقل وجه تضمین: <span class="list ng-binding">3,500,000</span></li>
        <li class="menu-detail-li"> حداکثرحجم هر سفارش: <span class="list ng-binding">25</span></li>
        <li class="menu-detail-li"> اندازه قرارداد : <span class="list ng-binding">100 گرم</span></li>
        <li class="menu-detail-li"> حد نوسان قیمت روزانه: <span class="list ng-binding"> از 128,200 تا 141,600 </span></li>
      </ul>
  </legend>
  <div class="partition" id="topLayot" ng-class="{hide:item.showMinSize}">
    <div class="deal" ng-class="{ w100: hideBidAsk || hideTradeBox}">
      <div class="deal-label-r"><label class="deal-label" tooltip-left="" tooltip=""><!-- ngIf: !editing --><input type="text" ng-if="!editing" ng-model="item.Price" ng-click="inputFocus()" ts="" required="" placeholder="قیمت :" class="ng-pristine ng-untouched ng-scope ng-empty ng-invalid ng-invalid-required"><!-- end ngIf: !editing --><!-- ngIf: editing --><i class="Font Ico-angle-up action" ng-click="priceUp(item)"></i><i class="Font Ico-angle-down action" ng-click="priceDown(item)"></i></label>
        <label
          class="deal-label count"><input type="text" ng-model="item.Quantity" ts="" ng-keydown="quantityInputKeyPress(item,$event)" required="" placeholder="تعداد :" class="ng-pristine ng-untouched ng-empty ng-invalid ng-invalid-required"><i class="Font Ico-angle-up action" ng-click="quantityUp(item)"></i>
          <i
            class="Font Ico-angle-down action" ng-click="quantityDown(item)"></i>
            </label>
      </div>
      <div class="deal-label"><button class="contract-button buy" ng-click="sendOrder(0, item)">خرید</button><button class="contract-button cansel" ng-click="clearBoxes(item)">انصراف</button><button class="contract-button sell" ng-click="sendOrder(1, item)">فروش</button></div>
    </div>
    <!-- ngIf: !hideBidAsk -->
    <div class="partition-p1 columns ng-scope" ng-if="!hideBidAsk" ng-class="{ w100: hideTradeBox}">
      <table class="table-layot-center bid-ask-table">
        <thead>
          <tr class="secondTr">
            <th>حجم</th>
            <th>قیمت</th>
            <th>قیمت</th>
            <th>حجم</th>
          </tr>
        </thead>
        <tbody>
          <tr class="Contents">
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.BidVolume1" ng-dblclick="changeVolume(item,item.pushMarketWatchData.BidVolume1)" id="_BidVolume1" class="BidStyle ng-binding flashCell">17</td>
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.BidPrice1" ng-dblclick="changePrice(item,item.pushMarketWatchData.BidPrice1)" id="_Bidprice1" class="BidStyle ng-binding flashCell">136,500</td>
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.AskPrice1" ng-dblclick="changePrice(item,item.pushMarketWatchData.AskPrice1)" id="_AskPrice1" class="AskStyle ng-binding flashCell">136,900</td>
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.AskVolume1" ng-dblclick="changeVolume(item,item.pushMarketWatchData.AskVolume1)" id="_AskVolume1" class="AskStyle ng-binding flashCell">15</td>
          </tr>
          <tr class="Contents">
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.BidVolume2" ng-dblclick="changeVolume(item,item.pushMarketWatchData.BidVolume2)" id="_BidVolume2" class="BidStyle ng-binding flashCell">63</td>
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.BidPrice2" ng-dblclick="changePrice(item,item.pushMarketWatchData.BidPrice2)" id="_BidPrice2" class="BidStyle ng-binding flashCell">136,400</td>
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.AskPrice2" ng-dblclick="changePrice(item,item.pushMarketWatchData.AskPrice2)" id="_AskPrice2" class="AskStyle ng-binding flashCell">137,000</td>
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.AskVolume2" ng-dblclick="changeVolume(item,item.pushMarketWatchData.AskVolume2)" id="_AskVolume2" class="AskStyle ng-binding flashCell">11</td>
          </tr>
          <tr class="Contents">
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.BidVolume3" ng-dblclick="changeVolume(item,item.pushMarketWatchData.BidVolume3)" id="_BidVolume3" class="BidStyle ng-binding flashCell">76</td>
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.BidPrice3" ng-dblclick="changePrice(item,item.pushMarketWatchData.BidPrice3)" id="_BidPrice3" class="BidStyle ng-binding flashCell">136,300</td>
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.AskPrice3" ng-dblclick="changePrice(item,item.pushMarketWatchData.AskPrice3)" id="_AskPrice3" class="AskStyle ng-binding flashCell">137,100</td>
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.AskVolume3" ng-dblclick="changeVolume(item,item.pushMarketWatchData.AskVolume3)" id="_AskVolume3" class="AskStyle ng-binding flashCell">68</td>
          </tr>
        </tbody>
      </table>
    </div>
    <!-- end ngIf: !hideBidAsk -->
    <!-- ngIf: !hideTradeBox -->
    <div class="partition-p2 columns ng-scope" ng-if="!hideTradeBox" ng-class="{ w100: hideBidAsk}">
      <table class="info-table">
        <thead>
          <tr>
            <th> اولین </th>
            <th> بالاترین </th>
            <th> پایین ترین </th>
            <th> آخرین </th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td class="unitValue ng-binding flashCell" style="cursor: pointer" flash-cell="item.pushMarketWatchData.FirstTradedPrice" id="_FirstTradedPrice" ng-dblclick="changePrice(item,item.pushMarketWatchData.FirstTradedPrice)"> 137,200 </td>
            <td class="unitValue ng-binding flashCell" style="cursor: pointer" flash-cell="item.pushMarketWatchData.HighTradedPrice" id="_HighTradedPrice" ng-dblclick="changePrice(item,item.pushMarketWatchData.HighTradedPrice)"> 137,900 </td>
            <td class="unitValue ng-binding flashCell" style="cursor: pointer" flash-cell="item.pushMarketWatchData.LowTradedPrice" id="_LowTradedPrice" ng-dblclick="changePrice(item,item.pushMarketWatchData.LowTradedPrice)"> 133,700 </td>
            <td class="unitValue bold ng-binding flashCell" style="cursor: pointer" flash-cell="item.pushMarketWatchData.LastTradedPrice" id="_LastTradedPrice" ng-dblclick="changePrice(item,item.pushMarketWatchData.LastTradedPrice)"> 136,600 </td>
          </tr>
          <tr>
            <td class="unitChange  ng-binding raiseUp flashCell" flash-cell="item.pushMarketWatchData.FirstTradedPriceChange" id="_C_FirstTradedPriceChange" dir="ltr" ng-class="{ raiseDown:item.pushMarketWatchData.FirstTradedPriceChange < 0, raiseUp:item.pushMarketWatchData.FirstTradedPriceChange > 0}">
            2,291 </td>
            <td class="unitChange  ng-binding raiseUp flashCell" flash-cell="item.pushMarketWatchData.HighTradedPriceChange" id="_C_HighTradedPriceChange" dir="ltr" ng-class="{ raiseDown:item.pushMarketWatchData.HighTradedPriceChange < 0,raiseUp:item.pushMarketWatchData.HighTradedPriceChange > 0 }">
            2,991 </td>
            <td class="unitChange  ng-binding raiseDown flashCell" flash-cell="item.pushMarketWatchData.LastTradedPriceChange" id="_C_LowTradedPriceChange" dir="ltr" ng-class="{ raiseDown:item.pushMarketWatchData.LowTradedPriceChange < 0,raiseUp:item.pushMarketWatchData.LowTradedPriceChange > 0 }">
            -1,209 </td>
            <td class="unitChange  ng-binding raiseUp flashCell" flash-cell="item.pushMarketWatchData.LastTradedPriceChange" id="_C_LastTradedPriceChange" dir="ltr" ng-class="{ raiseDown:item.pushMarketWatchData.LastTradedPriceChange < 0,raiseUp:item.pushMarketWatchData.LastTradedPriceChange > 0 }">
            1,691 </td>
          </tr>
          <tr>
            <td class="unitChange top ng-binding raiseUp flashCell" flash-cell="item.pushMarketWatchData.FirstTradedPriceChangePercent" id="_C_FirstTradedPriceChangesPercent" dir="ltr" ng-class="{ raiseDown:item.pushMarketWatchData.FirstTradedPriceChangePercent < 0,raiseUp:item.pushMarketWatchData.FirstTradedPriceChangePercent > 0 }">
            1.7 % </td>
            <td class="unitChange top ng-binding raiseUp flashCell" flash-cell="item.pushMarketWatchData.HighTradedPriceChangePercent" id="_C_HighTradedPriceChangesPercent" dir="ltr" ng-class="{ raiseDown:item.pushMarketWatchData.HighTradedPriceChangePercent < 0,raiseUp:item.pushMarketWatchData.HighTradedPriceChangePercent > 0 }">
            2.22 % </td>
            <td class="unitChange top ng-binding raiseDown flashCell" flash-cell="item.pushMarketWatchData.LowTradedPriceChangePercent" id="_C_LowTradedPriceChangesPercent" dir="ltr" ng-class="{ raiseDown:item.pushMarketWatchData.LowTradedPriceChangePercent < 0,raiseUp:item.pushMarketWatchData.LowTradedPriceChangePercent > 0 }">
            -0.9 % </td>
            <td class="unitChange top ng-binding raiseUp flashCell" flash-cell="item.pushMarketWatchData.LastTradedPriceChangePercent" id="_C_LastTradedPriceChangesPercent" dir="ltr" ng-class="{ raiseDown:item.pushMarketWatchData.LastTradedPriceChangePercent < 0 ,raiseUp:item.pushMarketWatchData.LastTradedPriceChangePercent > 0 }">
            1.25 % </td>
          </tr>
        </tbody>
      </table>
    </div>
    <!-- end ngIf: !hideTradeBox -->
    <div id="_PersianOrdersDateTime" class="date-time" title="زمان آخرین به روزرسانی سفارشات"><span flash-cell="item.pushMarketWatchData.OrdersDateTime" class="flashCellDark ng-binding flashCell"> به روز رسانی: دوشنبه 3 تیر 1398 - 16:47:28 </span></div>
    <!-- ngIf: !hideSettlementPrice -->
    <div class="partition-p3 columns ng-scope" ng-if="!hideSettlementPrice">
      <div class="readonlyForm">
        <div class="row five">
          <div class="column">
            <p class="title">قیمت تسویه لحظه ای</p>
            <p class="value ng-binding">136,062</p>
          </div>
          <div class="column">
            <p class="title">قیمت تسویه روز قبل</p>
            <p class="value ng-binding">134,909</p>
          </div>
          <div class="column">
            <p class="title">حجم</p>
            <p class="value ng-binding">5,887</p>
          </div>
          <div class="column">
            <p class="title">ارزش</p>
            <p class="value ng-binding">80,099,900</p>
          </div>
          <div class="column">
            <p class="title">موقعیت های باز</p>
            <p class="value ng-binding" style="direction: ltr"> 15,855 <span style="margin: 0px 0px 0px 15px; color: red;" ng-style="{color: item.pushMarketWatchData.OpenInterestsChanges < 0 ? 'red' : '#06B6A6' }" class="ng-binding"> -184 </span></p><span></span></div>
        </div>
      </div>
    </div>
    <!-- end ngIf: !hideSettlementPrice -->
  </div>
</fieldset>

The other element's code:

<fieldset class="fieldset ui-state-default ng-scope" id="229" ng-repeat="item in $root.selectedMarketWatch" ng-class="{ fullWidth:$root.uiSettings.fullWidthTable || item.showMaxSize || openLeft }" ng-hide="item.Hide">
  <legend class="legend Saffron" style="cursor: move"><span class="title ng-binding">SAFMO98    -</span><span class="title ng-binding">قرارداد آتی زعفران نگین تحویل مرداد ماه 1398                                                        </span><span class="Font Ico-info-circle sub-menu" ng-click="showSubMenu=!showSubMenu"></span>
    <i
      class="Font Ico-times" ng-click="$root.hideContract(item)"></i><i class="Font Ico-window-maximize" ng-click="fullSizeContract(item)"></i><i class="Font Ico-window-minimize" ng-click="minimizeContract(item)"></i>
      <ul class="menu-detail" ng-class="{ show:showSubMenu }">
        <li class="menu-detail-li"> سر رسید: <span class="list ng-binding">1398/05/26</span></li>
        <li class="menu-detail-li"> روز گواهی: <span class="list ng-binding">1398/05/26</span></li>
        <li class="menu-detail-li"> وجه تضمین: <span class="list ng-binding">5,000,000</span></li>
        <li class="menu-detail-li"> حداقل وجه تضمین: <span class="list ng-binding">3,500,000</span></li>
        <li class="menu-detail-li"> حداکثرحجم هر سفارش: <span class="list ng-binding">25</span></li>
        <li class="menu-detail-li"> اندازه قرارداد : <span class="list ng-binding">100 گرم</span></li>
        <li class="menu-detail-li"> حد نوسان قیمت روزانه: <span class="list ng-binding"> از 137,900 تا 152,300 </span></li>
      </ul>
  </legend>
  <div class="partition" id="topLayot" ng-class="{hide:item.showMinSize}">
    <div class="deal" ng-class="{ w100: hideBidAsk || hideTradeBox}">
      <div class="deal-label-r"><label class="deal-label" tooltip-left="" tooltip=""><!-- ngIf: !editing --><input type="text" ng-if="!editing" ng-model="item.Price" ng-click="inputFocus()" ts="" required="" placeholder="قیمت :" class="ng-pristine ng-untouched ng-scope ng-empty ng-invalid ng-invalid-required"><!-- end ngIf: !editing --><!-- ngIf: editing --><i class="Font Ico-angle-up action" ng-click="priceUp(item)"></i><i class="Font Ico-angle-down action" ng-click="priceDown(item)"></i></label>
        <label
          class="deal-label count"><input type="text" ng-model="item.Quantity" ts="" ng-keydown="quantityInputKeyPress(item,$event)" required="" placeholder="تعداد :" class="ng-pristine ng-untouched ng-empty ng-invalid ng-invalid-required"><i class="Font Ico-angle-up action" ng-click="quantityUp(item)"></i>
          <i
            class="Font Ico-angle-down action" ng-click="quantityDown(item)"></i>
            </label>
      </div>
      <div class="deal-label"><button class="contract-button buy" ng-click="sendOrder(0, item)">خرید</button><button class="contract-button cansel" ng-click="clearBoxes(item)">انصراف</button><button class="contract-button sell" ng-click="sendOrder(1, item)">فروش</button></div>
    </div>
    <!-- ngIf: !hideBidAsk -->
    <div class="partition-p1 columns ng-scope" ng-if="!hideBidAsk" ng-class="{ w100: hideTradeBox}">
      <table class="table-layot-center bid-ask-table">
        <thead>
          <tr class="secondTr">
            <th>حجم</th>
            <th>قیمت</th>
            <th>قیمت</th>
            <th>حجم</th>
          </tr>
        </thead>
        <tbody>
          <tr class="Contents">
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.BidVolume1" ng-dblclick="changeVolume(item,item.pushMarketWatchData.BidVolume1)" id="_BidVolume1" class="BidStyle ng-binding flashCell">16</td>
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.BidPrice1" ng-dblclick="changePrice(item,item.pushMarketWatchData.BidPrice1)" id="_Bidprice1" class="BidStyle ng-binding flashCell">146,700</td>
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.AskPrice1" ng-dblclick="changePrice(item,item.pushMarketWatchData.AskPrice1)" id="_AskPrice1" class="AskStyle ng-binding flashCell">146,800</td>
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.AskVolume1" ng-dblclick="changeVolume(item,item.pushMarketWatchData.AskVolume1)" id="_AskVolume1" class="AskStyle ng-binding flashCell">23</td>
          </tr>
          <tr class="Contents">
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.BidVolume2" ng-dblclick="changeVolume(item,item.pushMarketWatchData.BidVolume2)" id="_BidVolume2" class="BidStyle ng-binding flashCell">73</td>
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.BidPrice2" ng-dblclick="changePrice(item,item.pushMarketWatchData.BidPrice2)" id="_BidPrice2" class="BidStyle ng-binding flashCell">146,600</td>
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.AskPrice2" ng-dblclick="changePrice(item,item.pushMarketWatchData.AskPrice2)" id="_AskPrice2" class="AskStyle ng-binding flashCell">146,900</td>
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.AskVolume2" ng-dblclick="changeVolume(item,item.pushMarketWatchData.AskVolume2)" id="_AskVolume2" class="AskStyle ng-binding flashCell">22</td>
          </tr>
          <tr class="Contents">
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.BidVolume3" ng-dblclick="changeVolume(item,item.pushMarketWatchData.BidVolume3)" id="_BidVolume3" class="BidStyle ng-binding flashCell">179</td>
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.BidPrice3" ng-dblclick="changePrice(item,item.pushMarketWatchData.BidPrice3)" id="_BidPrice3" class="BidStyle ng-binding flashCell">146,500</td>
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.AskPrice3" ng-dblclick="changePrice(item,item.pushMarketWatchData.AskPrice3)" id="_AskPrice3" class="AskStyle ng-binding flashCell">147,000</td>
            <td style="cursor: pointer" flash-cell="item.pushMarketWatchData.AskVolume3" ng-dblclick="changeVolume(item,item.pushMarketWatchData.AskVolume3)" id="_AskVolume3" class="AskStyle ng-binding flashCell">156</td>
          </tr>
        </tbody>
      </table>
    </div>
    <!-- end ngIf: !hideBidAsk -->
    <!-- ngIf: !hideTradeBox -->
    <div class="partition-p2 columns ng-scope" ng-if="!hideTradeBox" ng-class="{ w100: hideBidAsk}">
      <table class="info-table">
        <thead>
          <tr>
            <th> اولین </th>
            <th> بالاترین </th>
            <th> پایین ترین </th>
            <th> آخرین </th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td class="unitValue ng-binding flashCell" style="cursor: pointer" flash-cell="item.pushMarketWatchData.FirstTradedPrice" id="_FirstTradedPrice" ng-dblclick="changePrice(item,item.pushMarketWatchData.FirstTradedPrice)"> 148,300 </td>
            <td class="unitValue ng-binding flashCell" style="cursor: pointer" flash-cell="item.pushMarketWatchData.HighTradedPrice" id="_HighTradedPrice" ng-dblclick="changePrice(item,item.pushMarketWatchData.HighTradedPrice)"> 148,400 </td>
            <td class="unitValue ng-binding flashCell" style="cursor: pointer" flash-cell="item.pushMarketWatchData.LowTradedPrice" id="_LowTradedPrice" ng-dblclick="changePrice(item,item.pushMarketWatchData.LowTradedPrice)"> 143,200 </td>
            <td class="unitValue bold ng-binding flashCell" style="cursor: pointer" flash-cell="item.pushMarketWatchData.LastTradedPrice" id="_LastTradedPrice" ng-dblclick="changePrice(item,item.pushMarketWatchData.LastTradedPrice)"> 146,800 </td>
          </tr>
          <tr>
            <td class="unitChange  ng-binding raiseUp flashCell" flash-cell="item.pushMarketWatchData.FirstTradedPriceChange" id="_C_FirstTradedPriceChange" dir="ltr" ng-class="{ raiseDown:item.pushMarketWatchData.FirstTradedPriceChange < 0, raiseUp:item.pushMarketWatchData.FirstTradedPriceChange > 0}">
            3,213 </td>
            <td class="unitChange  ng-binding raiseUp flashCell" flash-cell="item.pushMarketWatchData.HighTradedPriceChange" id="_C_HighTradedPriceChange" dir="ltr" ng-class="{ raiseDown:item.pushMarketWatchData.HighTradedPriceChange < 0,raiseUp:item.pushMarketWatchData.HighTradedPriceChange > 0 }">
            3,313 </td>
            <td class="unitChange  ng-binding raiseDown flashCell" flash-cell="item.pushMarketWatchData.LastTradedPriceChange" id="_C_LowTradedPriceChange" dir="ltr" ng-class="{ raiseDown:item.pushMarketWatchData.LowTradedPriceChange < 0,raiseUp:item.pushMarketWatchData.LowTradedPriceChange > 0 }">
            -1,887 </td>
            <td class="unitChange  ng-binding raiseUp flashCell" flash-cell="item.pushMarketWatchData.LastTradedPriceChange" id="_C_LastTradedPriceChange" dir="ltr" ng-class="{ raiseDown:item.pushMarketWatchData.LastTradedPriceChange < 0,raiseUp:item.pushMarketWatchData.LastTradedPriceChange > 0 }">
            1,713 </td>
          </tr>
          <tr>
            <td class="unitChange top ng-binding raiseUp flashCell" flash-cell="item.pushMarketWatchData.FirstTradedPriceChangePercent" id="_C_FirstTradedPriceChangesPercent" dir="ltr" ng-class="{ raiseDown:item.pushMarketWatchData.FirstTradedPriceChangePercent < 0,raiseUp:item.pushMarketWatchData.FirstTradedPriceChangePercent > 0 }">
            2.21 % </td>
            <td class="unitChange top ng-binding raiseUp flashCell" flash-cell="item.pushMarketWatchData.HighTradedPriceChangePercent" id="_C_HighTradedPriceChangesPercent" dir="ltr" ng-class="{ raiseDown:item.pushMarketWatchData.HighTradedPriceChangePercent < 0,raiseUp:item.pushMarketWatchData.HighTradedPriceChangePercent > 0 }">
            2.28 % </td>
            <td class="unitChange top ng-binding raiseDown flashCell" flash-cell="item.pushMarketWatchData.LowTradedPriceChangePercent" id="_C_LowTradedPriceChangesPercent" dir="ltr" ng-class="{ raiseDown:item.pushMarketWatchData.LowTradedPriceChangePercent < 0,raiseUp:item.pushMarketWatchData.LowTradedPriceChangePercent > 0 }">
            -1.3 % </td>
            <td class="unitChange top ng-binding raiseUp flashCell" flash-cell="item.pushMarketWatchData.LastTradedPriceChangePercent" id="_C_LastTradedPriceChangesPercent" dir="ltr" ng-class="{ raiseDown:item.pushMarketWatchData.LastTradedPriceChangePercent < 0 ,raiseUp:item.pushMarketWatchData.LastTradedPriceChangePercent > 0 }">
            1.18 % </td>
          </tr>
        </tbody>
      </table>
    </div>
    <!-- end ngIf: !hideTradeBox -->
    <div id="_PersianOrdersDateTime" class="date-time" title="زمان آخرین به روزرسانی سفارشات"><span flash-cell="item.pushMarketWatchData.OrdersDateTime" class="flashCellDark ng-binding flashCell"> به روز رسانی: دوشنبه 3 تیر 1398 - 16:49:47 </span></div>
    <!-- ngIf: !hideSettlementPrice -->
    <div class="partition-p3 columns ng-scope" ng-if="!hideSettlementPrice">
      <div class="readonlyForm">
        <div class="row five">
          <div class="column">
            <p class="title">قیمت تسویه لحظه ای</p>
            <p class="value ng-binding">146,215</p>
          </div>
          <div class="column">
            <p class="title">قیمت تسویه روز قبل</p>
            <p class="value ng-binding">145,087</p>
          </div>
          <div class="column">
            <p class="title">حجم</p>
            <p class="value ng-binding">39,418</p>
          </div>
          <div class="column">
            <p class="title">ارزش</p>
            <p class="value ng-binding">576,351,940</p>
          </div>
          <div class="column">
            <p class="title">موقعیت های باز</p>
            <p class="value ng-binding" style="direction: ltr"> 36,355 <span style="margin: 0px 0px 0px 15px; color: rgb(6, 182, 166);" ng-style="{color: item.pushMarketWatchData.OpenInterestsChanges < 0 ? 'red' : '#06B6A6' }" class="ng-binding"> 2,002 </span></p><span></span></div>
        </div>
      </div>
    </div>
    <!-- end ngIf: !hideSettlementPrice -->
  </div>
</fieldset>

The code I use for the test is this:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium import webdriver
import time
from selenium.webdriver.common.keys import Keys

driver = webdriver.Chrome("chromedriver.exe")
driver.set_page_load_timeout(10)
driver.get("https://something.com")
time.sleep(45)
login = driver.find_element_by_id("submit-btn")
login.send_keys(Keys.RETURN)
driver.refresh()

driver.set_page_load_timeout(10)
price = driver.find_element_by_xpath("//input[@class='ng-pristine ng-untouched ng-scope ng-empty ng-invalid ng-invalid-required' and starts-with(@ng-click, 'inputFocus')'][contains(@ng-model, 'Price') and @placeholder='قیمت :']")
price.send_keys("1")
price.send_keys(Keys.RETURN)
time.sleep(4)
driver.quit()
Moshe Slavin
  • 5,127
  • 5
  • 23
  • 38
Hasani
  • 3,543
  • 14
  • 65
  • 125
  • 1
    you can look for the "ng-model" value - I'm assuming that must be unique: https://stackoverflow.com/questions/31792301/locating-an-element-using-ng-model-using-selenium-in-python – David Lavender Jun 24 '19 at 10:05
  • 1
    You'll need to provide us with the HTML or the website for us to help you. – Moshe Slavin Jun 24 '19 at 10:29
  • @Hasani Instead of changing the question you need to provide the feedback for any answer publish it as a comment below the respective answer. Please don't update the main question. – undetected Selenium Jun 24 '19 at 11:13
  • @DavidLavender: The message was greater than comments container! – Hasani Jun 24 '19 at 11:20
  • @MosheSlavin: The web site has a login page. – Hasani Jun 24 '19 at 11:21
  • @Hasani use index or provide more HTML content probably 4-5 lines around target element so that we can provide an unique locator. – Saurabh Gaur Jun 24 '19 at 11:31
  • 1
    To echo @MosheSlavin, you need to provide more HTML. The basic strategy is to find an element that contains the element you are trying to get, and specify that in your XPATH or CSS selector: `//div[@id = 'someId']//input[@type = 'text' and @ng-model = 'item.Price']` – Greg Burghardt Jun 24 '19 at 11:38
  • @SaurabhGaur: I added more `HTML` code. – Hasani Jun 24 '19 at 12:20
  • @Hasani I have provided unique xpath locators with the answer, please look into this and let me know.. :) – Saurabh Gaur Jun 25 '19 at 06:13

4 Answers4

1

Use following unique xpaths :

  1. For your first HTML :

    //span[contains(text(), 'SAFTR98')]/ancestor::fieldset//input[@ng-model='item.Price']
    
  2. For your second HTML :

    //span[contains(text(), 'SAFMO98')]/ancestor::fieldset//input[@ng-model='item.Price']
    

Hope it helps.

Saurabh Gaur
  • 23,507
  • 10
  • 54
  • 73
  • Thank you Saurabh! Unfortunately this is market time and my laptop is under running another program. I will test your code surely 5 hours later. – Hasani Jun 25 '19 at 07:36
  • @Hasani Sure.. no problem.. :) – Saurabh Gaur Jun 25 '19 at 07:37
  • 1
    You are GREAT! Sorry if I did it so late. I was so busy. I tested your code now and it worked. Thank you very much. Please add some explanation to your answer and teach how to find other elements of the page? – Hasani Jun 28 '19 at 17:22
  • I also have another question. What I am trying to do is writing a robot trader for myself. In the page there is a box that when I send an order, my order request will be shown in that box(other list). But as this is off time of the market, I can not find any elements related to the order list. I will add the code of the list to my question's `EDIT2` part. Please help me there too. – Hasani Jun 28 '19 at 17:30
  • 1
    Unfortunately the question contents exceeds limitation, so I had to create a new question here https://stackoverflow.com/questions/56811247/how-to-find-an-element-that-seems-only-works-in-some-times – Hasani Jun 28 '19 at 17:48
0

To find the desired element you can use either of the following Locator Strategies:

  • CSS:

    "input.ng-pristine.ng-untouched.ng-scope.ng-empty.ng-invalid.ng-invalid-required[ng-click^='inputFocus][ng-model$='Price'][placeholder='قیمت :']"
    
  • XPATH:

    "//input[@class='ng-pristine ng-untouched ng-scope ng-empty ng-invalid ng-invalid-required' and starts-with(@ng-click, 'inputFocus')'][contains(@ng-model, 'Price') and @placeholder='قیمت :']"
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • What if some elements have exactly same xpaths? – Hasani Jun 24 '19 at 10:48
  • @Hasani Updated the answer, let me know the status please. Incase the locators still doesn't identifies the element uniquely you need to update the relevant HTML with the elements parent HTML as well – undetected Selenium Jun 24 '19 at 11:11
  • @Hasani if 2 elements have exact same xpath, then we can use xpath indexing like `(//input[@type='text'])[1] - element 1` `(//input[@type='text'])[2] - element 2` – Amit Jain Jun 24 '19 at 11:17
0

Most likely same element on another DOM branch. Try take parent element with something unique.

In my case, it's been like:

//*[@id='ma-modal__body']/child::*[@ng-if='!editing']

Read about XPath Axes. There is many different element relationships in DOM. I hope helped!

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Amerousful
  • 2,292
  • 1
  • 12
  • 26
0

Probably the best way would be sticking to ng-model attribute value, the relevant XPath expression would be:

//input[@ng-model='item.Price']

You might also want to use Explicit Wait to ensure that the element is present and can be interacted:

new org.openqa.selenium.support.ui.WebDriverWait(driver, 10)
        .until(
                ExpectedConditions.elementToBeClickable(
                        By.xpath("//input[@ng-model='item.Price']")))
Dmitri T
  • 159,985
  • 5
  • 83
  • 133