I'd like to use xpath to select a link whose class="watchListItem"
, span="icon icon_checked"
, and h3="a test"
. I can use xpath to get either matching link and span, or link and h3, but not link, span, and h3.
Here's what I've tried:
//*[@class = 'watchListItem']/span[@class = 'icon icon_checked']
//*[@class= 'watchListItem']/h3[text()='AA']
I'm looking for something like this:
//*[@class = 'watchListItem']//*[span[@class = 'icon icon_checked'] and h3[text()='AA']]
<li>
<a class="watchListItem" data-id="thisid1" href="javascript:void(0);">
<span class="icon icon_checked"/>
<h3 class="itemList_heading">a test</h3>
</a>
</li>
<li>
<a class="watchListItem" data-id="thisid2" href="javascript:void(0);">
<span class="icon icon_unchecked"/>
<h3 class="itemList_heading">another test</h3>
</a>
</li>
<li>
<a class="watchListItem" data-id="thisid3" href="javascript:void(0);">
<span class="icon icon_checked"/>
<h3 class="itemList_heading">yet another test</h3>
</a>
</li>
You can use the child::
location paths like so:
//a[@class="watchListItem"
and child::span[@class="icon icon_checked"]
and child::h3[text()="another test"]]
This would select the anchor with data-id="thisid3"
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With