98. child XPath Axes (Selenium Java 2026)
Child XPath Axes child:: Axis The child:: axis selects all direct children of the current node. Key Idea A parent tag contains child tags child:: selects only direct children (not deeper descendants) Practical Demonstrations //body[@id='xyz']/child::p[1] → Selects the first p child of body with id = xyz //body[@id='xyz']/p[1] → Shortcut version (child:: is optional since it's the default axis) //html/child::head/child::title → Selects title inside head inside html //html/child::body/child::p → Selects all p elements that are direct children of body //html/child::body/child::p[1] → Selects the first p child of body //html/child::body/child::p[@id='para1'] → Selects p elements with id = para1 that are direct children of body Notes child:: is the default axis in XPath, so it can be omitted Example: child::p = p Only immediate children are selected, not nested elements
Download
0 formatsNo download links available.