Friday, June 9, 2017

WebDriver - Find XPath

WebDriver - Find XPath


In this post we will first see how to install Firebug and later a simple example of how to use Firebug in order to find XPath.

Download and install Firebug. Its a Firefox Add-in.

Launch Firefox. Go to Tools (menu) -> Web Developer -> Get More Tools.

Web Developer's Toolbox page opens and install the Firebug add-on.

Now as the Firebug is installed, lets see a simple example of its usage to find the XPath.

Lets suppose we have this table. You can also see below the HTML code of the table.



Right-click on the element, for example if we need to find element 3 in the table, right-click on it and select Inspect Element with Firebug.

It shows the element as HTML code as can be seen below. Right-click on it and select Copy XPath.

The XPath which is copied above is:


The same XPath is being used in this code to find an element and printing its text on the console.