xpath_2
xpath_2
1. following-sibling
The Xpath sibling axis is similar to the axis that comes after it. Only sibling nodes, i.e.
nodes on the same level as the current node, are recognised by following-sibling.
We can make use of this when the class names are same .
2. preceding-sibling
What is preceding sibling in XPath?
The preceding-sibling axis indicates all the nodes that have the same parent as the
context node and appear before the context node in the source document.
sibling:attribute
Example 1: Consider there are two fields, first name and last name. To locate the
//select[@id='fname']/following-sibling::select
Xpath- //ul[@id='mega-menu-primary']//following-sibling::li
child.
Example 4: Orange HRM site
Here we can locate “Qualification” using the class name of “job” .
sibling:attribute
Example 1:
Xpath- //li[@id='mega-menu-item-138328']//preceding-sibling::li
The Above Xpath will locate the first preceding or the first web element in the
current level.