Selenium interacts with GUI elements available on a web page through its commands. These commands identify the web elements by using locators. Click here & here to understand about Selenium locators in detail. There are multiple ways to generate the locators using Web Browser. You can use the inbuilt inspector in different browsers. If you are using Mozilla Firefox then these two Add-ons are very useful: FireBug & FirePath. Both add-ons help you to generate desired locators. There is another Plugin “Webdriver Element Locator” provided by Firefox which does not only generate XPath locators for the Web Element, but also it gives you Webdriver script/command in desired programming language.
Webdriver Element Locator helps you to speed up the selenium code writing by easing the process of locating the element. It also gives you multiple XPath options for single web element. This plugin only generated XPath locators. For other locators like id & CSS Selectors you will need FireBug and FirePath add-ons.
Now let’s look at the process of installing this beautiful plugin and then we will see how to use it.
Installation steps of Webdriver Element Locator:
– Open www.google com in Firefox Browser and search “Webdriver Element Locator plugin”.
– Go to first link displayed in the result.
– Press “Continue to Download” button.
– Press “Install” from the browser fly-out.
You will see a message “Webdriver Element Locator” installed successfully.
Use of Webdriver Element Locator:
– Open a website/webpage which you wish to automate.
– For this example, we are going to use www.testingjournals.com Logo Image.
– Right click on any element and observe that additional options related to “Webdriver Element Locator” are added to the list. Refer below Image.
– I want to automate Selenium Webdriver in Java programming language, so I will select Java Locators. You can use any desired option based on your programming language.
– After selecting any option, it gets copied to clipboard. Use any editor to paste your code.
Webdriver Element Locator helps you to generate best XPath Locator for your Web Element and also provides Selenium Webdriver Code in selected programming language. Use this Plugin and Speed Up your automation code writing.
Are you aware of any other Add-on or Plugin which can be used to ease our day to day activities? Please let me know. Don’t forget to share your feedback.