Professional Documents
Culture Documents
1. Child axes:
i. The child axis is one of the 13 XPath axes that contains all the child
nodes of the current context. It selects all children elements of the
current node.
2. Parent Axes:
i. The parent axis selects the parent of the current node. The parent
node may be either root node or element node. The root node has
no parent.
ii. XPath(Parent node): //input[@id = 'text']//parent::span (1 of 1
matched)
3. Ancestor Axis:
i. The ancestor axis selects all ancestor elements (parent, grandparent,
great-grandparents, etc.) of the current node. This axis always
contains the root node (unless the current node is the root node).
4. Descendant Axis:
i. The descendant axis selects all descendant elements (children,
grandchildren, etc) of the current node. Let’s take an example to
understand the concepts of the descendant axis.
5. Following-sibling:
i. We can use the concept of following-sibling in xpath for identifying
elements in Selenium. It identifies the siblings of the context node.
The siblings should be located at the equal level of the existing node
and should have the same parent.
ii. Let us see an example of an element with ul tag having more than
one child with li tag. Then let us try to locate the fifth li element
(Effective Resume Writing) from the first li element with class
attribute sreading
iii. //li[@class='sreading']/following-sibling::li[4]
6. Following:
i. following: This function will return the immediate element of the
particular component.
iii. Xpath=//*[@type='text']//following::input
7. Preceding-sibling:
i. This one indicates all the sibling nodes (same parent as context node)
that appear before the context node in the HTML DOM structure. This
does NOT indicate descendent, attribute, and namespace.
ii.
XPath: //a[text() = 'Videos']//preceding-sibling::a (1 of 3)
8. Preceding:
i. This indicates all the nodes that appear before the context node in the HTML
DOM structure. This does NOT indicate descendent, attribute, and
namespace.
ii. XPath: //input[@id = 'u_0_2']//preceding::input (1 of 4 matched).