I already tried using the ">" syntax but selenium does not accept it, I know there is a way to get it using Xpath but our entire project is written using CSS selectors.
I am trying to store a list that will contain all immediate children of an element but not their children (descendants), when I use the "*" syntax I get all the element's descendants.
I already tried using the ">" syntax but selenium does not accept it, I know there is a way to get it using Xpath but our entire project is written using CSS selectors.
I am trying to store a list that will contain all immediate children of an element but not their children (descendants), when I use the "*" syntax I get all the element's descendants.
Share Improve this question edited Nov 23, 2011 at 13:04 Shiran asked Nov 23, 2011 at 12:25 ShiranShiran 1971 gold badge1 silver badge4 bronze badges 3 |1 Answer
Reset to default 31You should specify a tag to start from... if you want "all element's immediate children", you would simply get all elements, which isn't really what you want.
To get "all immediate children of an element but not their children" for body
, use body > *
.
Or another example, to get all direct descendants of <div id='question'>
, use div#question > *
.
body > *
does not give you all direct descendants of the body tag in Selenium? – jro Commented Nov 23, 2011 at 12:32