Reputation: 18705
I'm trying to find tags meeting some condition but just those on the first level (relatively) (not their children etc.). I don't want to find their children, grandchildren etc. whose meeting the condition. Is it possible?
I'm using Selenium with Python
<div id="example1">
<div id="example2">
</div>
</div>
<div id="example3">
</div>
I want to return example1
and example3
(not example2
).
Those div
s can be a children of a body
but they can be also grandchildren etc. so driver.find_element_by_css_selector(body > div[name*=example])
is not enough.
Upvotes: 1
Views: 87
Reputation: 16232
Something like this could do the trick:
*:not([id*=example]) > [id*=example]
http://codepen.io/anon/pen/EVxYjE
Upvotes: 1