Reputation: 57
Recently I came across an XPath locator value which has "/../"
in between.
What is the meaning of it?
Context XPath:
//*[contains(@class, 'xyz')]//*[contains(text(), 'text')]
/../*[contains(@class, 'className')]
Upvotes: 0
Views: 2497
Reputation: 111541
/../
in XPath1Relatively, /../node()
selects the parent's children of the
context node:
/
separates location steps. /..
selects the parents of the context node because ..
is an abbreviation for parent::
./../
introduces an incomplete next step./../node()
would select the parent's children nodes.Absolutely, /../node()
selects nothing.
/
selects the root node./..
selects nothing because the root node has no parent./../
introduces an incomplete next step./../node()
would select nothing because /..
selected nothing.1. Note that by itself, /../
is syntactically invalid; below assumes its part of a valid XPath.
Upvotes: 3