I am trying to find the list item based on the contents in the anchor.
I tried using the following xpath
//li/a[contains(., 'India')]
It is working for unique items, But here, it is matching more than one item.
I want to ignore the the other contents in anchor and only focus on the anchor text to identify the li. How can i achieve it?
<ul>
<li style="display: list-item;"><a href="#"><img src="1" class="flag"> Afghanistan</a></li>
<li style="display: list-item;"><a href="#"><img src="2" class="flag"> India</a></li>
<li style="display: list-item;"><a href="#"><img src="3" class="flag"> British Indian Ocean Territory</a></li>
</ul>
PS: Tried the following, it works. But later if the position of "  ;" changes, it's going to fail.
//li/a[ends-with(normalize-space(.),'India')]