0
0
Selenium Pythontesting~5 mins

XPath axes (parent, child, sibling) in Selenium Python - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the parent axis in XPath?
The parent axis selects the parent node of the current node in the XML or HTML document tree.
Click to reveal answer
beginner
How does the child axis work in XPath?
The child axis selects all child nodes of the current node. It is often used to find direct descendants.
Click to reveal answer
intermediate
Explain the following-sibling axis in XPath.
The following-sibling axis selects all sibling nodes that come after the current node on the same level in the document tree.
Click to reveal answer
intermediate
Write an XPath expression to select the parent of a node with id 'item'.
XPath: //*[@id='item']/parent::* selects the parent node of the element with id 'item'.
Click to reveal answer
intermediate
What is the difference between child:: and // in XPath?
child:: selects only direct children of the current node, while // selects nodes at any depth (descendants) from the current node.
Click to reveal answer
Which XPath axis selects the parent of the current node?
Aparent
Bchild
Cfollowing-sibling
Ddescendant
What does the XPath child::div select?
AAll div elements anywhere in the document
BAll div elements that are direct children of the current node
CThe parent div of the current node
DAll sibling div elements after the current node
Which XPath axis would you use to select siblings after the current node?
Aparent
Bpreceding-sibling
Cchild
Dfollowing-sibling
What is the result of //*[@id='item']/parent::*?
ASelects the node with id 'item'
BSelects all children of the node with id 'item'
CSelects the parent of the node with id 'item'
DSelects all siblings of the node with id 'item'
Which axis selects only direct children nodes?
Achild
Bfollowing-sibling
Cdescendant
Dancestor
Describe how you would use XPath axes to navigate from a child element to its parent and then to its following sibling.
Think about moving up first, then sideways in the document tree.
You got /3 concepts.
    Explain the difference between the child and following-sibling XPath axes with examples.
    Consider the tree structure and node relationships.
    You got /3 concepts.