XPath stands for XML Path Language. It is a query language used for locating nodes in an XML document. A webpage is built on HTML, but since HTML is also one form of XML, XPaths are widely used in HTML documents by Test Automation Engineers to locate various elements on a webpage.
There are 2 types of XPaths,
Let us explore some of the key concepts used in XPaths
1. NodesNode forms the building block of an XML document. A node can be an element, attribute, text, comment or a processing instruction within an XML or HTML document. It starts with angular brackets such as <h1>, <input>, <img>, <a href=””>, etc.
Some of the common types of node are:
XPath expressions are strings which are used to locate the nodes in an XML or HTML document. It consists of a sequence of steps containing a combination of node, their filtering criteria and are separated using slashes (/).
Axes are the set of keywords used in an XPath expression to define the relationship between two nodes. These are used to locate an element using the relative location with respect to a reference element.
Some of the commonly used axes are
We shall explore these axes in depth in further tutorials.
Predicates are nothing but the filtering criterias used to filter nodes based on certain conditions. They are represented within the square brackets [], against any node.
Fully customizable CRM Software for Freelancers and Small Businesses