selenium webdriver - How to click on one link among several to which all of them having same id -


how click on 1 link among several of them having same id. , has 1 means through can it,that id. , through xpath ,we can't because every time open tab,location of link changes,so xpath changes too. there lots of links having same id,it differs through text written above it.so refer link,i mention through text,but still not able do.

in other words,there links(with images) placed 1 one,on execution,i want 3 link execute executes first 1 due having same id's.so should click third link not first one.

<span class="online-signal"></span>  <figure>      <img id="userimagepreview" src='/content/patientphotos/default.jpg' alt="" />  </figure>  <figcaption class="doc-des-cap" title="y">z </figcaption>  <figcaption>rating: 4</figcaption>  <span class="select-btn">      <a id="linkappointment" docid="727" docname="x" href="javascript:void(0)">select</a>  </span>  <span class="offline-signal"></span>  <figure>      <img id="userimagepreview" src='/content/patientphotos/default.jpg' alt="" />  </figure>  <figcaption class="doc-des-cap" title="c">b</figcaption>  <figcaption>rating: 0</figcaption>  <span class="select-btn">      <a id="linkappointment" docid="49" docname="a" href="javascript:void(0)">select</a>  </span> 

try using below xpath

//figcaption[contains(@title, 'y')]/preceding-sibling::figure/img[@id='userimagepreview'] 

replace title <figcaption> title attribute of respective img want locate

hope helps you...if still not working kindly back


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -