views:

56

answers:

1

Guys, I'm trying to write xpath or css to find/click on list element "All" based on known span(in this case SNG NAME below). On page, there are different lists Which can contain same list item called as "All". So we have to identify "All" based on span(in this case SNG NAME below)

can someone shed some light on my issue

<html>
  <head>
    <body>
     <div class="grc_selected">
       <div class ="lbl_selected">
          <span> SNG NAME </span>
       </div>
      <div id="id1" class="cl1">
        <ul id="id_ul">
          <li class="tclass" title="[1] All">
                <img class="treeIcon" src="1/2/3.gif"/>
                <span class="inA">All</span>
          </li>
        </ul>
     </div>
  </body>
 </head>
</html>
+2  A: 

You could use an XPath query like:

//div[span=" SNG NAME "]/following-sibling::div//span[.="All"]

That targets the div which contains the span whose text value is SNG NAME, then moves to the following div (id1) and finally targets the span inside it containing the text All. This makes the assumption that the HTML is fixed (there's currently mismatching div tags) in such a way that the above query structure makes sense (by placing the missing closing div tag between the </ul> and final </div>).

salathe
very cool. xpath you provided works very well. Appreciate your time. Thanks
doneright
this is answered
doneright