I have an application that requires me to find a XPath selector for an element and then see if that XPath can be simplified.
So if I have
<a class="abc def gh">
I may determine that the XPath
a[contains(@class, "abc")
is specific enough. The problem is, it also selects items with class "abcxyz",
Is there a way to select items with ONLY class "abc"?
i.e. I think it's clear but I want to find items that have a class of "abc" or "abc def" but not "abcxyz".
Here's a more specific example because I believe neither of the answers so far works:
<div>
<span id="x" class="btnSalePriceLabel">Sale:</span>
<span id="y" class="btnSalePrice highlight">$20.40</span>
</div>
I want whatever XPath selector will select the 2nd span and not the first.
If I try
//span[@class and contains(concat(' ', normalize-space(@class), ' '), ' btnSalesPrice ')]
I get nothing selected. Likewise with
//span[contains(concat(' ', normalize-space(@class), ' '), ' btnSalesPrice ')]