Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

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.

1 Answer

0 votes
by (62.9k points)
edited by

You should specify a tag to start out from, if you want "all element's immediate children", you'd easily get all elements, but that isn't what you really want.

To get "all immediate children of an element but not their children" for the body, use 

body > *.

Or another example would be if you want to get all direct descendants of <div id='question'>, use div#question > *.

If you are interested to learn Selenium on a much deeper level and want to become a professional in the testing domain, check out Intellipaat’s Selenium certification online!

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...