selenium - Find out correct xpath -


i have html page this:

... <div class="container">     <div class="title">meat</div>     <div class="someclass">         <div class="tile aaa">             <div class="text">aaa</div>             <img class="image" src="somewhat.jpg" />         </div>     </div>     <div class="someclass">         <div class="tile bbb">             <div class="text">bbb</div>             <img class="image" src="somewhat.jpg" />         </div>     </div> </div>  <div class="container">     <div class="title">fish</div>     <div class="someclass">         <div class="tile aaa">             <div class="text">aaa</div>             <img class="image" src="somewhat.jpg" />         </div>     </div>     <div class="someclass">         <div class="tile bbb">             <div class="text">bbb</div>             <img class="image" src="somewhat.jpg" />         </div>     </div> </div> ... 

i need able selenium click img specific element (for example, want meat-bbb's img) can't find way xpath

any appreciated...

this click on meat-bbb's img:

driver.findelement(by.xpath("//div[.='meat']/following-sibling::*[2]//img")).click(); 

it finds 2nd sibling div element having text/innerhtml "meat", , traverses first "img" element in it.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -