This session explains XPath axes in Selenium with Java, focusing on DOM navigation and key XPath terminology for effective element location.
Key Takeaways
- XPath axes enable flexible navigation through the DOM beyond simple attribute-based selection.
- Understanding DOM node relationships (self, parent, child, ancestor, descendant, sibling) is crucial for writing effective XPath expressions.
- XPath axes help locate elements even when attributes are missing by leveraging node hierarchy.
- Siblings are nodes sharing the same parent, with preceding and following siblings defined by their position relative to the self node.
- Mastering XPath axes improves element selection strategies in Selenium automation.
Summary
- Recap of XPath basics and introduction to XPath axes for advanced DOM navigation.
- Explanation of how XPath axes allow navigation top-to-bottom and bottom-to-top in the DOM.
- Detailed discussion on XPath terminology: self node, parent, child, ancestor, descendant, sibling, preceding sibling, and following sibling.
- Use of XPath axes to locate elements without attributes by traversing related nodes.
- Illustration of DOM structure and hierarchy with examples to clarify relationships between nodes.
- Explanation of ancestor as parent of parent and descendant as child of child nodes.
- Clarification on sibling nodes as elements sharing the same parent.
- Examples provided to identify siblings, preceding siblings, and following siblings in the DOM.
- Emphasis on understanding terminology first to effectively use XPath axes in Selenium.
- Encouragement to review previous session materials for foundational XPath knowledge.











