Trying to create a XPath to find input elements with a specific label on my website. However I want it to not be found if its ancestor is a specific div.
Assume we got the following HTML:
<div class="content"> <div class="abc"> <div> //some other elements </div> <div> <h2>Name</h2> <input></input> </div> </div> <div> <div> //some other elements </div> <div> <h2>Name</h2> <input></input> </div> </div> </div> I only want to find the name input in the div that does not have the surrounding div "abc".
I have this that only finds the name input if it's in the the abc wrapper but can't make it find the other way around:
//div[contains(@class, 'content')]//div[contains(@class, 'abc')]//descendant::h2[.='Name']/following-sibling::input I thought I could use a not() function around the contains(abc) like so:
[not(contains(@class, 'abc'))] But it did not work.