Install WebDriver Element Locator Add-On To Get XPath Of Element Easily

As you know, XPath Is most Important element locator to automate you web application using selenium WebDriver. There are many other locators are also available In WebDriver but If you don't know about XPath locator then It will be very hard for you to prepare WebDriver test cases. Earlier we learnt how to find XPath of element manually In THIS POST

Finding XPath manually Is time consuming process and WebDriver Element Locator Firefox add-on can help you to get element's XPath very easily. If you will use this add on then you do not need to Inspect element using firebug but you will get It In just two clicks. I am using this add-on from very long time and It helps me very much so let me tell you how to Install and use It If any one of you want It. Mean time you can read how to install firebug and firepath add-ons in firefox browser to get xpath of any element in THIS POST.

Steps to download and Install WebDriver Element Locator Add-On
If you have Installed any firefox add-on before then you will be well aware about Installation process. Ok.. let me tell you how to Install It.

  • Open Firefox Browser.
  • Go to https://addons.mozilla.org/en-US/firefox/. You will sind add-ons search box at top right corner of that page.
  • Search for add on using "WebDriver Element Locator" keyword. It will show you list of add on In search result.
  • Click on "Add to Firefox" button of "WebDriver Element Locator" add on as shown In bellow Image.
  • It will show you popup to Install "WebDriver Element Locator" add on. Click on Install Now button as bellow. It will start Installing add on.



  • At the end of Installation, It will show you add on successfully Installed message as bellow. That means add on Is Installed successfully. You can view Installed add on at Firefox browser menu -> Tools -> Add ons -> Extension section.

How to get Element's XPath using add on
Now you can get any element's XPath In just two clicks. Follow the steps given bellow to get XPath of Google search box.
  • Open http://www.google.com/ In Firefox browser.
  • Right click on Google search text box. It will show you multiple language options (C# Locators, Java Locators, Python Locators, Ruby Locators etc.) to get xpath syntax of Google search box as bellow. You can select language as per your requirement. I am using Java so I need XPath string In java compatible format.
  • As sown In above Image, It will show you many XPath syntax for Google searchbox when move mouse on Java Locators. XPath syntax marked with YES sign will work properly In your script so click on any of the XPath syntax to copy It.
  • Now you can paste It In your eclipse IDE directly and use It In your script.
This way you can get any web element's XPath In just two clicks as shown above using WebDriver Element Locator Add-On.

5 comments: