4

I am trying to find first fridge IMG element in a e-Commerce page but I could not find it alone, It's identifying all Images under First DIV.. Please share you thoughts

I tried below XPATH, is there any way identify first image element uniquely

//a[@class='_1UoZlX'][1]//img[1] -- 7 elements identified

(//a[@class='_1UoZlX'])[1]//IMG[1] -- 2 elements identified

Link Here

or HTML code

<div class="GQtpzo" data-reactid="80">

<div class="_15eYWX">
<!-- react-empty: 2131 -->

<div class="GSPgJx">

<div class="_1joEet">

<div class="_1HEvv0"><a class="_1KHd47" href="/">Home</a><svg width="16" height="27" viewBox="0 0 16 27" xmlns="http://www.w3.org/2000/svg" class="_2XP0B_">

<path d="M16 23.207L6.11 13.161 16 3.093 12.955 0 0 13.161l12.955 13.161z" fill="#fff" class="_24NaUy"></path></svg>
</div>

<div class="_1HEvv0"><a class="_1KHd47" href="/home-kitchen/pr?sid=j9e">Home &amp; Kitchen</a><svg width="16" height="27" viewBox="0 0 16 27" xmlns="http://www.w3.org/2000/svg" class="_2XP0B_">

<path d="M16 23.207L6.11 13.161 16 3.093 12.955 0 0 13.161l12.955 13.161z" fill="#fff" class="_24NaUy"></path></svg>
</div>

<div class="_1HEvv0"><a class="_1KHd47" href="/home-kitchen/home-appliances/pr?sid=j9e,abm">Home Appliances</a><svg width="16" height="27" viewBox="0 0 16 27" xmlns="http://www.w3.org/2000/svg" class="_2XP0B_">

<path d="M16 23.207L6.11 13.161 16 3.093 12.955 0 0 13.161l12.955 13.161z" fill="#fff" class="_24NaUy"></path></svg>
</div>

<div class="_1HEvv0"><a class="_1KHd47" href="/home-kitchen/home-appliances/refrigerators/pr?sid=j9e,abm,hzg">Refrigerators</a><svg width="16" height="27" viewBox="0 0 16 27" xmlns="http://www.w3.org/2000/svg" class="_2XP0B_">

<path d="M16 23.207L6.11 13.161 16 3.093 12.955 0 0 13.161l12.955 13.161z" fill="#fff" class="_24NaUy"></path></svg>
</div>
</div>

<div class="KG9X1F"><h1 class="_1ZODb3">

<span>

<span>Showing 
</span>

<span>1
</span>

<span> – 
</span>

<span>4
</span>

<span> of 
</span>

<span>4
</span>

<span> results for "
</span>

<span>

<span class="W-gt5y">refrigerator
</span>
</span>

<span>"
</span>
</span></h1>
</div>
</div>
</div>

<div class="_92OsvN _1AXZMV">

<div class="_2Z12CV"><section class="_2_hjz5">

<span class="_1No1qI">

<span>

<span>Sort By
</span>
</span>
</span>
<ul class="_3fPYHw">
<li class="_2Ylh8t">Relevance</li>
<li class="_2Ylh8t">Popularity</li>
<li class="_2Ylh8t _3q0Dpv">Price -- Low to High</li>
<li class="_2Ylh8t">Price -- High to Low</li>
<li class="_2Ylh8t">Newest First</li>
<li class="_2Ylh8t">Discount</li>
</ul></section>
</div>
</div>

<div>

<div class="_2SxMvQ">

<div class="_3T_wwx">

<div class="col _2-gKeQ"><a class="_1UoZlX" target="_blank" rel="noopener noreferrer" href="/godrej-260-l-frost-free-double-door-refrigerator/p/itmekwxweqzygpuf?pid=RFREKWXW4YE6RYNZ&amp;srno=s_1_1&amp;otracker=search&amp;lid=LSTRFREKWXW4YE6RYNZWKUE1E&amp;qH=9ed5270571c7d513">

<div class="_3SQWE6">

<div class="_1OCn9C">

<div class="">

<div class="_3BTv9X" style="height: 200px; width: 200px;"><img class="_1Nyybr _30XEf0 xh-highlight" alt="Godrej 260 L Frost Free Double Door Refrigerator" src="https://rukminim1.flixcart.com/image/312/312/refrigerator-new/y/n/z/godrej-rt-eon-260-p-2-4-original-imaekyfqptszbdwr.jpeg?q=70">
</div>
</div>
<!-- react-empty: 2195 -->

<div class="_2lesQu">

<div class="_2VmCve _1pNWV5">

<span class="_1nUZxV">

<div class="_2kFyHg">
<label>
<input type="checkbox" class="_3uUUD5" readonly="" value="on">

<div class="_1p7h2j">
</div>
</label>
</div>
</span>
<label class="_2RgZpB">

<span>

<span>Add to Compare
</span>
</span>
</label>
</div>
</div>
</div>

<div class="_3gDSOa _32A6AP">

<div class="DsQ2eg">

<span class="_22jaBC">
</span>

<span class="r9OBmc">

<span class="_3I1Lzl">
</span>

<span class="_3I1Lzl">
</span>

<span class="_3I1Lzl">
</span>

<span class="_3I1Lzl">
</span>
</span><svg xmlns="http://www.w3.org/2000/svg" class="_2oLiqr" width="16" height="16" viewBox="0 0 10 18" preserveAspectRatio="xMinYMax meet">

<path d="M7.695 15.35C3.06 11.14 0 8.356 0 4.958 0 2.172 2.178 0 4.95 0 6.516 0 9.164 1.764 9 2.91 9.164 1.763 11.484 0 13.05 0 15.822 0 18 2.172 18 4.958c0 3.398-3.06 6.183-7.695 10.392L9 16.54l-1.305-1.19z" class="_35Y7Yo"></path></svg>
</div>
</div>
</div>

<div class="_1-2Iqu row">

<div class="col col-7-12">

<div class="_3wU53n">Godrej 260 L Frost Free Double Door Refrigerator
</div>

<div class="OiPjke">RT EON 260 P 2.4, Silver Strokes, 2016
</div>

<div class="niH0FQ">

<span id="productRating_LSTRFREKWXW4YE6RYNZWKUE1E" class="_2_KrJI">

<div class="hGSR34 _2beYZw">

<span>
<!-- react-text: 2224 -->4
<!-- /react-text -->

<span class="_1M5rur">★
</span>
</span>
</div>

<div class="_11cw91 tDKdrX _1JkwFc E753YP _29B81u _3qgmUP rating-tooltip">

<div class="_2h52bo _15sV4W _2dmlTA">

<div class="row">

<div class="col-4-12">

<div class="col">

<div class="row">

<div class="col-12-12">

<div class="_1i0wk8">4
</div>

<div class="_2txNna">★
</div>
</div>
</div>

<div class="row _2yc1Qo">

<div class="col-12-12">

<span>

<span>
</span>

<span>138
</span>

<span> Ratings
</span>
</span>
</div>
</div>

<div class="row _2yc1Qo">

<div class="col-12-12">

<span>

<span>
</span>

<span>35
</span>

<span> Reviews
</span>
</span>
</div>
</div>
</div>
</div>

<div class="col-7-12">

<div class="_1n1j36 DrZOea ">
<ul>
<li class="_58ZIbs">

<div class="_1atKHO col col-2-12">

<span class="_3ApwOG">5
</span>

<span class="_2bhdZh">★
</span>
</div>

<div class="col col-7-12">

<div class="_1WmLa3">

<span class="_1Yym6V euq4L_" style="width: 100%;">
</span>
</div>
</div>

<div class="col col-3-12">

<div class="CamDho">&nbsp;62
</div>
</div></li>
<li class="_58ZIbs">

<div class="_1atKHO col col-2-12">

<span class="_3ApwOG">4
</span>

<span class="_2bhdZh">★
</span>
</div>

<div class="col col-7-12">

<div class="_1WmLa3">

<span class="_1Yym6V _2YFTec" style="width: 72.5806%;">
</span>
</div>
</div>

<div class="col col-3-12">

<div class="CamDho">&nbsp;45
</div>
</div></li>
<li class="_58ZIbs">

<div class="_1atKHO col col-2-12">

<span class="_3ApwOG">3
</span>

<span class="_2bhdZh">★
</span>
</div>

<div class="col col-7-12">

<div class="_1WmLa3">

<span class="_1Yym6V _33mvU5" style="width: 24.1935%;">
</span>
</div>
</div>

<div class="col col-3-12">

<div class="CamDho">&nbsp;15
</div>
</div></li>
<li class="_58ZIbs">

<div class="_1atKHO col col-2-12">

<span class="_3ApwOG">2
</span>

<span class="_2bhdZh">★
</span>
</div>

<div class="col col-7-12">

<div class="_1WmLa3">

<span class="_1Yym6V _2MYUs6" style="width: 3.22581%;">
</span>
</div>
</div>

<div class="col col-3-12">

<div class="CamDho">&nbsp;2
</div>
</div></li>
<li class="_58ZIbs">

<div class="_1atKHO col col-2-12">

<span class="_3ApwOG">1
</span>

<span class="_2bhdZh">★
</span>
</div>

<div class="col col-7-12">

<div class="_1WmLa3">

<span class="_1Yym6V _1sq5Tn" style="width: 22.5806%;">
</span>
</div>
</div>

<div class="col col-3-12">

<div class="CamDho">&nbsp;14
</div>
</div></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</span>

<span class="_38sUEc">

<span>

<span>138 Ratings&nbsp;
</span>

<span class="_1VpSqZ">&amp;
</span>

<span>&nbsp;35 Reviews
</span>
</span>
</span>
</div>

<div class="_3ULzGw">
<ul class="vFw0gD">
<li class="tVe95H">2 Star BEE Rating 2016 2</li>
<li class="tVe95H">Normal Compressor for low maintenance costs</li>
<li class="tVe95H">10 Years on Compressor &amp; 1 Year on Refrigerator</li>
</ul>
</div>
</div>

<div class="col col-5-12 _2o7WAb">

<div class="_6BWGkk">

<div class="_1uv9Cb">

<div class="_1vC4OE _2rQ-NK">
<!-- react-text: 2240 -->₹
<!-- /react-text -->
<!-- react-text: 2241 -->19,499
<!-- /react-text -->
</div>

<div class="_3auQ3N _2GcJzG">
<!-- react-text: 2243 -->₹
<!-- /react-text -->
<!-- react-text: 2244 -->24,810
<!-- /react-text -->
</div>

<div class="VGWI6T">
<!-- react-text: 2246 -->21
<!-- /react-text -->
<!-- react-text: 2247 -->% off
<!-- /react-text -->
</div>
</div>
</div>

<div class="_3n6o0t"><img height="21" src="//img1a.flixcart.com/www/linchpin/fk-cp-zion/img/fa_8b4b59.png" class="xh-highlight">
</div>

<div class="_3rwXI6">

<span>

<span>Up to 
</span>

<span>

<span class="_2xjzPG">₹3,200
</span>
</span>

<span> Off on Exchange
</span>
</span>
</div>

<div class="_3MCpsc">
<!-- react-text: 2257 -->EMI starting from 
<!-- /react-text -->

<span class="_1JT2XE">
<!-- react-text: 2259 -->₹
<!-- /react-text -->
<!-- react-text: 2260 -->946
<!-- /react-text -->
<!-- react-text: 2261 -->/month
<!-- /react-text -->
</span>
</div>

<div class="OPF9v4 _2WQngC">

<span class="_1xZuAn">

<span>Offers
</span>
</span>
<ul class="_3U7997">
<li class="_1ZRRx1">No Cost EMI</li>
<li class="_1ZRRx1">Bank Offer</li>
</ul>
</div>
</div>
</div></a>
</div>

<div class="col _2-gKeQ"><a class="_1UoZlX" target="_blank" rel="noopener noreferrer" href="/whirlpool-292-l-frost-free-double-door-refrigerator/p/itmeuypqukjskpbq?pid=RFREFRM2FZYHMCZH&amp;srno=s_1_2&amp;otracker=search&amp;lid=LSTRFREFRM2FZYHMCZHXYQHED&amp;qH=9ed5270571c7d513">

<div class="_3SQWE6">

<div class="_1OCn9C">

<div style="filter: grayscale(1); opacity: 0.6;">

<div class="_3BTv9X" style="height: 200px; width: 200px;"><img class="_1Nyybr _30XEf0" alt="Whirlpool 292 L Frost Free Double Door Refrigerator" src="https://rukminim1.flixcart.com/image/312/312/refrigerator-new/c/z/h/whirlpool-neo-fr305-roy-plus-3s-original-imaefy2yakwzmgaw.jpeg?q=70">
</div>
</div>

<div class="_3aV9Tq">

<span class="_1GJ2ZM">Out Of Stock
</span>
</div>

<div class="_2lesQu">

<div class="_2VmCve _1pNWV5">

<span class="_1nUZxV">

<div class="_2kFyHg">
<label>
<input type="checkbox" class="_3uUUD5" readonly="" value="on">

<div class="_1p7h2j">
</div>
</label>
</div>
</span>
<label class="_2RgZpB">

<span>

<span>Add to Compare
</span>
</span>
</label>
</div>
</div>
</div>

<div class="_3gDSOa _32A6AP">

<div class="DsQ2eg">

<span class="_22jaBC">
</span>

<span class="r9OBmc">

<span class="_3I1Lzl">
</span>

<span class="_3I1Lzl">
</span>

<span class="_3I1Lzl">
</span>

<span class="_3I1Lzl">
</span>
</span><svg xmlns="http://www.w3.org/2000/svg" class="_2oLiqr" width="16" height="16" viewBox="0 0 10 18" preserveAspectRatio="xMinYMax meet">

<path d="M7.695 15.35C3.06 11.14 0 8.356 0 4.958 0 2.172 2.178 0 4.95 0 6.516 0 9.164 1.764 9 2.91 9.164 1.763 11.484 0 13.05 0 15.822 0 18 2.172 18 4.958c0 3.398-3.06 6.183-7.695 10.392L9 16.54l-1.305-1.19z" class="_35Y7Yo"></path></svg>
</div>
</div>
</div>

<div class="_1-2Iqu row">

<div class="col col-7-12">

<div class="_3wU53n">Whirlpool 292 L Frost Free Double Door Refrigerator
</div>

<div class="OiPjke">NEO FR305 ROY PLUS 3S, Alpha Steel, 2017
</div>

<div class="niH0FQ">

<span id="productRating_LSTRFREFRM2FZYHMCZHXYQHED" class="_2_KrJI">

<div class="hGSR34 _2beYZw">

<span>
<!-- react-text: 2305 -->4.6
<!-- /react-text -->

<span class="_1M5rur">★
</span>
</span>
</div>
</span>

<span class="_38sUEc">

<span>

<span>64 Ratings&nbsp;
</span>

<span class="_1VpSqZ">&amp;
</span>

<span>&nbsp;13 Reviews
</span>
</span>
</span>
</div>

<div class="_3ULzGw">
<ul class="vFw0gD">
<li class="tVe95H">3 Star BEE Rating 2017 3</li>
<li class="tVe95H">Reciprocatory Compressor</li>
<li class="tVe95H">1 Year on Refrigerator &amp; 10 Years on Compressor</li>
</ul>
</div>
</div>

<div class="col col-5-12 _2o7WAb">

<div class="_6BWGkk">

<div class="_1uv9Cb">

<div class="_1vC4OE _2rQ-NK">
<!-- react-text: 2321 -->₹
<!-- /react-text -->
<!-- react-text: 2322 -->24,000
<!-- /react-text -->
</div>

<div class="_3auQ3N _2GcJzG">
<!-- react-text: 2324 -->₹
<!-- /react-text -->
<!-- react-text: 2325 -->32,400
<!-- /react-text -->
</div>

<div class="VGWI6T">
<!-- react-text: 2327 -->25
<!-- /react-text -->
<!-- react-text: 2328 -->% off
<!-- /react-text -->
</div>
</div>
</div>

<div class="_3MCpsc">
<!-- react-text: 2330 -->EMI starting from 
<!-- /react-text -->

<span class="_1JT2XE">
<!-- react-text: 2332 -->₹
<!-- /react-text -->
<!-- react-text: 2333 -->1164
<!-- /react-text -->
<!-- react-text: 2334 -->/month
<!-- /react-text -->
</span>
</div>
<!-- react-empty: 2335 -->
</div>
</div></a>
</div>

<div class="col _2-gKeQ"><a class="_1UoZlX" target="_blank" rel="noopener noreferrer" href="/panasonic-296-l-frost-free-double-door-refrigerator/p/itmem8qbaxxzjgp9?pid=RFREM8QBCKYHQZFP&amp;srno=s_1_3&amp;otracker=search&amp;lid=LSTRFREM8QBCKYHQZFPNEHASX&amp;qH=9ed5270571c7d513">

<div class="_3SQWE6">

<div class="_1OCn9C">

<div>

<div class="_3BTv9X" style="height: 200px; width: 200px;"><img class="_1Nyybr _30XEf0" alt="Panasonic 296 L Frost Free Double Door Refrigerator" src="https://rukminim1.flixcart.com/image/312/312/refrigerator-new/f/m/c/panasonic-nr-br347vsx1-original-imaemufj8w47dsza.jpeg?q=70">
</div>
</div>
<!-- react-empty: 2343 -->

<div class="_2lesQu">

<div class="_2VmCve _1pNWV5">

<span class="_1nUZxV">

<div class="_2kFyHg">
<label>
<input type="checkbox" class="_3uUUD5" readonly="" value="on">

<div class="_1p7h2j">
</div>
</label>
</div>
</span>
<label class="_2RgZpB">

<span>

<span>Add to Compare
</span>
</span>
</label>
</div>
</div>
</div>

<div class="_3gDSOa _32A6AP">

<div class="DsQ2eg">

<span class="_22jaBC">
</span>

<span class="r9OBmc">

<span class="_3I1Lzl">
</span>

<span class="_3I1Lzl">
</span>

<span class="_3I1Lzl">
</span>

<span class="_3I1Lzl">
</span>
</span><svg xmlns="http://www.w3.org/2000/svg" class="_2oLiqr" width="16" height="16" viewBox="0 0 10 18" preserveAspectRatio="xMinYMax meet">

<path d="M7.695 15.35C3.06 11.14 0 8.356 0 4.958 0 2.172 2.178 0 4.95 0 6.516 0 9.164 1.764 9 2.91 9.164 1.763 11.484 0 13.05 0 15.822 0 18 2.172 18 4.958c0 3.398-3.06 6.183-7.695 10.392L9 16.54l-1.305-1.19z" class="_35Y7Yo"></path></svg>
</div>
</div>
</div>

<div class="_1-2Iqu row">

<div class="col col-7-12">

<div class="_3wU53n">Panasonic 296 L Frost Free Double Door Refrigerator
</div>

<div class="OiPjke">NR-BR307VSX1, Shining Silver, 2016
</div>

<div class="niH0FQ">

<span id="productRating_LSTRFREM8QBCKYHQZFPNEHASX" class="_2_KrJI">

<div class="hGSR34 _2beYZw">

<span>
<!-- react-text: 2372 -->5
<!-- /react-text -->

<span class="_1M5rur">★
</span>
</span>
</div>
</span>

<span class="_38sUEc">

<span>

<span>4 Ratings&nbsp;
</span>

<span class="_1VpSqZ">&amp;
</span>

<span>&nbsp;0 Reviews
</span>
</span>
</span>
</div>

<div class="_3ULzGw">
<ul class="vFw0gD">
<li class="tVe95H">2 Star BEE Rating 2016 2</li>
<li class="tVe95H">Reciprocatory Inverter Compressor</li>
<li class="tVe95H">Built-in Stabilizer</li>
<li class="tVe95H">1 Year Comprehensive &amp; 9 Years on the Compressor</li>
</ul>
</div>
</div>

<div class="col col-5-12 _2o7WAb">

<div class="_6BWGkk">

<div class="_1uv9Cb">

<div class="_1vC4OE _2rQ-NK">
<!-- react-text: 2389 -->₹
<!-- /react-text -->
<!-- react-text: 2390 -->29,299
<!-- /react-text -->
</div>

<div class="_3auQ3N _2GcJzG">
<!-- react-text: 2392 -->₹
<!-- /react-text -->
<!-- react-text: 2393 -->38,500
<!-- /react-text -->
</div>

<div class="VGWI6T">
<!-- react-text: 2395 -->23
<!-- /react-text -->
<!-- react-text: 2396 -->% off
<!-- /react-text -->
</div>
</div>
</div>

<div class="_3n6o0t"><img height="21" src="//img1a.flixcart.com/www/linchpin/fk-cp-zion/img/fa_8b4b59.png" class="">
</div>

<div class="_3rwXI6">

<span>

<span>Up to 
</span>

<span>

<span class="_2xjzPG">₹3,200
</span>
</span>

<span> Off on Exchange
</span>
</span>
</div>

<div class="_3MCpsc">
<!-- react-text: 2406 -->EMI starting from 
<!-- /react-text -->

<span class="_1JT2XE">
<!-- react-text: 2408 -->₹
<!-- /react-text -->
<!-- react-text: 2409 -->1002
<!-- /react-text -->
<!-- react-text: 2410 -->/month
<!-- /react-text -->
</span>
</div>

<div class="OPF9v4 _2WQngC">

<span class="_1xZuAn">

<span>Offers
</span>
</span>
<ul class="_3U7997">
<li class="_1ZRRx1">Bank Offer</li>
</ul>
</div>
</div>
</div></a>
</div>

<div class="col _2-gKeQ"><a class="_1UoZlX" target="_blank" rel="noopener noreferrer" href="/panasonic-296-l-frost-free-double-door-refrigerator/p/itmem8qbhf7avnhn?pid=RFREM8QBSURREFX8&amp;srno=s_1_4&amp;otracker=search&amp;lid=LSTRFREM8QBSURREFX89D6SW4&amp;qH=9ed5270571c7d513">

<div class="_3SQWE6">

<div class="_1OCn9C">

<div>

<div class="_3BTv9X" style="height: 200px; width: 200px;"><img class="_1Nyybr" alt="Panasonic 296 L Frost Free Double Door Refrigerator">
</div>
</div>
<!-- react-empty: 2423 -->

<div class="_2lesQu">

<div class="_2VmCve _1pNWV5">

<span class="_1nUZxV">

<div class="_2kFyHg">
<label>
<input type="checkbox" class="_3uUUD5" readonly="" value="on">

<div class="_1p7h2j">
</div>
</label>
</div>
</span>
<label class="_2RgZpB">

<span>

<span>Add to Compare
</span>
</span>
</label>
</div>
</div>
</div>

<div class="_3gDSOa _32A6AP">

<div class="DsQ2eg">

<span class="_22jaBC">
</span>

<span class="r9OBmc">

<span class="_3I1Lzl">
</span>

<span class="_3I1Lzl">
</span>

<span class="_3I1Lzl">
</span>

<span class="_3I1Lzl">
</span>
</span><svg xmlns="http://www.w3.org/2000/svg" class="_2oLiqr" width="16" height="16" viewBox="0 0 10 18" preserveAspectRatio="xMinYMax meet">

<path d="M7.695 15.35C3.06 11.14 0 8.356 0 4.958 0 2.172 2.178 0 4.95 0 6.516 0 9.164 1.764 9 2.91 9.164 1.763 11.484 0 13.05 0 15.822 0 18 2.172 18 4.958c0 3.398-3.06 6.183-7.695 10.392L9 16.54l-1.305-1.19z" class="_35Y7Yo"></path></svg>
</div>
</div>
</div>

<div class="_1-2Iqu row">

<div class="col col-7-12">

<div class="_3wU53n">Panasonic 296 L Frost Free Double Door Refrigerator
</div>

<div class="OiPjke">NR-BR307XSX1, Stainless Steel, 2016
</div>

<div class="niH0FQ">

<span id="productRating_LSTRFREM8QBSURREFX89D6SW4" class="_2_KrJI">

<div class="hGSR34 _2beYZw">

<span>
<!-- react-text: 2452 -->4.7
<!-- /react-text -->

<span class="_1M5rur">★
</span>
</span>
</div>
</span>

<span class="_38sUEc">

<span>

<span>10 Ratings&nbsp;
</span>

<span class="_1VpSqZ">&amp;
</span>

<span>&nbsp;5 Reviews
</span>
</span>
</span>
</div>

<div class="_3ULzGw">
<ul class="vFw0gD">
<li class="tVe95H">2 Star BEE Rating 2016 2</li>
<li class="tVe95H">Reciprocatory Inverter Compressor</li>
<li class="tVe95H">Built-in Stabilizer</li>
<li class="tVe95H">1 Year Comprehensive &amp; 9 Years on the Compressor</li>
</ul>
</div>
</div>

<div class="col col-5-12 _2o7WAb">

<div class="_6BWGkk">

<div class="_1uv9Cb">

<div class="_1vC4OE _2rQ-NK">
<!-- react-text: 2469 -->₹
<!-- /react-text -->
<!-- react-text: 2470 -->31,499
<!-- /react-text -->
</div>

<div class="_3auQ3N _2GcJzG">
<!-- react-text: 2472 -->₹
<!-- /react-text -->
<!-- react-text: 2473 -->40,000
<!-- /react-text -->
</div>

<div class="VGWI6T">
<!-- react-text: 2475 -->21
<!-- /react-text -->
<!-- react-text: 2476 -->% off
<!-- /react-text -->
</div>
</div>
</div>

<div class="_3n6o0t"><img height="21" src="//img1a.flixcart.com/www/linchpin/fk-cp-zion/img/fa_8b4b59.png" class="">
</div>

<div class="_3rwXI6">

<span>

<span>Up to 
</span>

<span>

<span class="_2xjzPG">₹3,200
</span>
</span>

<span> Off on Exchange
</span>
</span>
</div>

<div class="_3MCpsc">
<!-- react-text: 2486 -->EMI starting from 
<!-- /react-text -->

<span class="_1JT2XE">
<!-- react-text: 2488 -->₹
<!-- /react-text -->
<!-- react-text: 2489 -->1077
<!-- /react-text -->
<!-- react-text: 2490 -->/month
<!-- /react-text -->
</span>
</div>

<div class="OPF9v4 _2WQngC">

<span class="_1xZuAn">

<span>Offers
</span>
</span>
<ul class="_3U7997">
<li class="_1ZRRx1">Bank Offer</li>
</ul>
</div>
</div>
</div></a>
</div>
</div>
</div>
</div>
</div>

4 Answers 4

3

This will get you the first result's img element:

(//a[@class='_1UoZlX']//img)[1]

Honestly though, this is a rat's nest from hell. If I were you I'd have a serious discussion with the developers about getting some tags in there that you can actually rely on. Right now there's very little in that page that can be located reliably.

1
 IList<IWebElement> list = driver.FindElements(By.TagName("img"));
 string aa = list[0].GetAttribute("src").ToString();

I would like to do somthing like this.

6
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review
    – Bharat Mane
    Commented Jul 2, 2017 at 18:17
  • Hi Bharat why did you say "This does not provide an answer to the question. Because he was asking how to get the 1st image.So what i did was get all the things which have img tag to an array and select the 1st element on it.
    – ChathuD
    Commented Jul 3, 2017 at 5:46
  • @ChathuD The problem with your answer is that you are getting the first img tag from all the img tags on the page. The question was how to get the first img from a specific subset of img tags on the page. Commented Jul 8, 2017 at 0:15
  • In that case user can edit the 1st line and search the img tag inside a specific area.Becouse when i write this code i was in a assumption where the 1st img tag will be the required img on the above web page.So how could my answer will be " This does not provide an answer to the question".
    – ChathuD
    Commented Jul 8, 2017 at 6:08
  • @ChathuD Hey man don't shoot the messenger. I was just letting you know what the problem was so you could fix it yourself. I've given a correct answer to the actual question asked and still got 3 down votes without anyone saying why. That's life :) Commented Jul 10, 2017 at 23:16
1

I would just let Selenium find the first img element - no need to do it via XPath manually:

IWebElement firstImage = driver.FindElement(By.TagName("img"));

Or, if you want to do it in the scope of the desired a element:

IWebElement firstImage = driver.FindElement(By.CssSelector("a._1UoZlX img"));
2
  • Hi @alecxe, surely a._1UoZlX img matches the same 2 img tags as (//a[@class='_1UoZlX'])[1]//IMG[1]? Commented Jul 8, 2017 at 0:57
  • @GeorgeMcConnon I don't think these two are equivalent. I was more up to using findElement to find the first occurrence of the desired element - the selector is just something concise and reasonable I've come up with..thanks.
    – alecxe
    Commented Jul 8, 2017 at 1:01
1

You should not use the _1UoZIX identifier. It's generated on the fly (dynamically) and changes over time. It also has no semantic meaning, doesn't say fridge at all

Getting to the 'first search result image' element generically, i.e. first result and not just when it is that fridge... is going to be a challenge given the layout. One approach that might work is (pseudo code) a locator that is something like

//div a[@href='/']/img[2]

i.e. find the main div based on the home anchor within it and then look for the second image within that div. I don't like this much but this is due to the page structure presented. Some version of this may work.

Also, unless you use relative addressing I prefer css locators for readability and compactness, e.g.

div a[href=''] img:nth-child(2)

In this case the CSS identifier is longer but that is fairly unusual.

2
  • 2
    I have updated the question with HTML Code, and I always wanted to select the first image element of the page.. So alt might not be the right choice for me ...
    – SQA_LEARN
    Commented Jul 2, 2017 at 13:40
  • Updated to not use the alt approach at all Commented Jul 8, 2017 at 10:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.