So XPath can be written is an XPath query to locate the author of a book whose category is children. Once I reach the correct node, the next step will be to pick a node with an author tag. book store, then I will locate a book whose category is children. Here, I will start with the root node i.e. As you can see in the below figure, both have 2 tags i.e. Category of 1st book type is cooking and 2nd is children. Here, the book store is a root node which has 2 children of type book. Now, let’s visualize this XML document in a tree-like structure. And this book node, in turn, has 2 child nodes i.e. It is further followed by an attribute called category whose value is Cooking. It starts with a tag called the bookstore, which is also an element or a node.Īs you can see here, the Bookstore node has a child node Book. Below figure is an example of an XML document where you have different tags and attributes. The XML document has a tree-like structure.
#XPATH FOR TEXT BOX IN SELENIUM HOW TO#
Now, let’s understand how to write an XPath for an XML Document. It is designed to allow the navigation of XML documents, with the purpose of selecting individual elements, attributes, or some other part of an XML document for specific processing. Here, you can easily write XPath script/query to locate any element in the webpage. It consists of a path expression along with some conditions. It is an important strategy to locate elements in selenium. XPath also called as XML Path is a language to query XML documents. This video on Xpath Tutorial talks about Xpath fundamentals and steps involved in writing a Xpath Script.