Tuesday 18 November 2014

WebDriver Element Locator Add-on

WebDriver element locator Add-on makes easy to find the elements XPath.
It is used to find the different XPaths for single web browser element.
Ex: different combination of XPath locators for 'Google Search' button in "http://www.google.com" page.

Easy to distinguish between unique and duplicate locators.
Populates the context menu with XPath based findElement API command for different programming & scripting languages like Java, C# , Python & Ruby

Context menu show XPath with red exclamation and green ticks.
XPath with red exclamation represents duplicate XPath, it alerts automation developers to avoid using the duplicate locators.
XPath with green ticks represents unique XPaths.

Webdriver Element Locator Add-on can be installed from the below URL:
https://addons.mozilla.org/en-US/firefox/addon/element-locator-for-webdriv/


Click on "Add to Firefox" button.

Click on "Allow"


Click "Install Now" button.

Click "Control" + "Shift" + "A" keyboard buttons and check "Webdriver Element Locator" Add-on is added to Firefox browser "Extenstions"


Capturing the XPath locator of the web browser element.
 - Open the url "www.google.com"
 - Mouse over the "Google Search" button.
 - Perform mouse right click
 - Context menu displayed.

Select XPaths in context menu.



Select the Unique XPath locator(i.e. XPath with green ticks) XPath is copied in to the clipboard.

Perform "Control" + "V" for adding the selected XPath locator with findElement API method in the script.

 Pros:
- Easy to find the XPath locators for the web elements.
- Able to distinguish between duplicate and unique XPath Locator.

 Cons:
- Limited only to XPath locators.
- Context menu doesn't show XPath with red exclamation and green ticks for few web elements(i.e. either it shows red exclamation or green ticks but not both for few web elements).

No comments:

Post a Comment