- Oct 10, 2018
- admin
- 0
An axis represents a relationship to the context (current) node, and is used to locate nodes relative to that node on the tree.
Examples:
Navigate to https://google.com..
//textarea[@name=’q’]//..//child::textarea
//textarea[@name=’q’]//..//parent::div
//textarea[@name=’q’]//self::textarea




- Navigate to https://techtutorialz.com..
- Mousehover on Tutorials menu item..
- Examples:
- //a[@title=’AWS Tutorial’]//..//following-sibling::li[1]/a :Find Blockchain Tutorial using “AWS Tutorial”
- //a[@title=’ADB Tutorial’]//..//following-sibling::li[1]/a :Find “Postman tutorial” using ADB Tutorial
- //a[@title=’ADB Tutorial’]//..//preceding-sibling::li[1]/a : Find “Artificial Intelligence” using “previous 1st sibling”ADB Tutorial”
- //a[@title=’AWS Tutorial’]//..//preceding-sibling::li[1]/a : Find “Postman Tutorial”
- //a[@title=’AWS Tutorial’]//..//preceding-sibling::li[2]/a : Find “ADB Tutorial” tutorial using “AWS Tutorial”
- //a[@title=’AWS Tutorial’]//..//..//..//descendant::li : Find descendent list items of “AWS Tutorial”
- //a[@title=’ADB Tutorial’]//..//ancestor::li/ul/child::li

AxisName | Result |
---|---|
ancestor | Selects all ancestors (parent, grandparent, etc.) of the current node |
ancestor-or-self | Selects all ancestors (parent, grandparent, etc.) of the current node and the current node itself |
attribute | Selects all attributes of the current node |
child | Selects all children of the current node |
descendant | Selects all descendants (children, grandchildren, etc.) of the current node |
descendant-or-self | Selects all descendants (children, grandchildren, etc.) of the current node and the current node itself |
following | Selects everything in the document after the closing tag of the current node |
following-sibling | Selects all siblings after the current node |
namespace | Selects all namespace nodes of the current node |
parent | Selects the parent of the current node |
preceding | Selects all nodes that appear before the current node in the document, except ancestors, attribute nodes and namespace nodes |
preceding-sibling | Selects all siblings before the current node |
self | Selects the current node |