Continuing with the Automation project, WebDriver allows to interact with the DOM (Document Object Model) through XPath . Xpath provides a quite interesting approach to query the DOM, but sometimes it requires dedication and practice to fully understand how it works and how the queries can be performed.
Since I need to interact with the DOM elements very often and WebDriver also provides a way to use XPath, then it is time to getting started using it.
I’ve been using Firebug for a while and I found a very interesting and helpful add-on called FirePath.
FirePath gives you the XPath expression to locate the element, look for example how easy is to find an element in google :
Let’s suppose I would like to find the dive where the country is displayed, then the XPath expression would be
This is another approach to interact with XPath.


Well, it is even easier if you use jQuery
which is why I usually start my O2 automation scripts with
ie.injectJQuery() ; // if it is not already there
which means that we can code similar XPATH query using the powerful jQuery selectors.
Also see https://github.com/o2platform/O2.Platform.Scripts/tree/master/APIs/_Javascript_Libraries/JQuery
Pingback: Best approach to find nested elements with WebDriver :When Xpath becomes your best friend | TeamMentor Development and Testing