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>
You could use an XPath query like:
That targets the
divwhich contains the span whose text value isSNG NAME, then moves to the followingdiv(id1) and finally targets the span inside it containing the textAll. This makes the assumption that the HTML is fixed (there’s currently mismatchingdivtags) in such a way that the above query structure makes sense (by placing the missing closingdivtag between the</ul>and final</div>).