Saturday, 5 May 2012

What is XPath?

XPath is normally called as XML Path.

We use XPath to navigate through elements, and attributes in the XML document.
As per W3C's, the XPath is a major element in XSLT standard - and XQuery and XPointer are both built on XPath expressions.

XPath is the language for finding information in an XML document.

What XPath is?
  • It is a syntax for defining parts of an XML document
  • It uses path expressions to navigate in XML documents
  • It contains the library of standard functions
  • It is vital element in XSLT
  • It is W3C recommendation

Normally in every web-based applications the XPaths or locators are unique addresses for each and every web object. It can be used with selenium to
perform operations on each object present in the webpage. In the web page each web-object has a primary unique XPath.

XPaths are derived from the html paths of the objects. One can install firebug, and on the top of firebug, one can install firpath. Both are installed as addons on Firefox.
When one extracts the xpath of the object, one can use that object using Selenium IDE, Selenium RC, or Selenium Web-driver. Xpaths are constants. They do rarely change. If there is a text-box, and the label of the text-box changes but the position does not change then xpath remains the same. Sometimes xpaths alo vary everytime you refresh the page. To handle variable XPath you need to use java-script functions. Varying xpaths always have a pattern.


  1. This comment has been removed by the author.

  2. It was very nice article and it is very useful to Selenium learners.We also provide Cub training software online training.