xpath find element's grandparent -
i'm bit stuck getting grandparent element xpath. unfortunately tries not successful :(
html
<span class="fsm fwn fcg"> <a href="bla bla"> <abbr> <span class="timestampcontent" id="js_19">21 mins</span> </abbr> </a> </span>
i need <a href="bla bla">
element grandparent <span class="timestampcontent" id="js_19">21 mins</span>
i tried smth like: //span[@class='timestampcontent' , contains(text(), 21 mins)]../..
or ../..//span[@class='timestampcontent' , contains(text(), 21 mins)]
and other options, didn't worked out :(
your first try close, /
before ..
missing (and missing quotes around '21 mins', believe typo) :
//span[@class='timestampcontent' , contains(text(), '21 mins')]/../..
alternatively, can other way around i.e selecting element has grand child span
of criteria :
//*[*/span[@class='timestampcontent' , contains(text(), '21 mins')]]
Comments
Post a Comment