How to find XPath in Selenium? It’s a common challenge that troubles every test automation developer using Selenium for web testing. Hence, we picked the seven most relevant Chrome Extensions that can help you find XPath in Selenium.
Introduction
XPath is the most powerful way of determining the locations of elements on a web page. Also, it’s the best locator strategy when you’ve to find objects that are highly dynamic and fragile. So it eventually becomes inevitable for every test automation developer to learn how to create custom XPath expressions.
XPath syntax is extremely extensible. It supports regular expression, array-like formation to index elements, and functions as well. So learning to build XPath is a continuous process that you master with time.
However, the Chrome browser has a number of extensions to help in determining the XPath of web elements. With these turnkey Chrome extensions, it’s a bit easier to generate the XPaths. In this post, we are going to share seven such extensions that our team has evaluated as the most relevant for finding the XPath in Selenium.
Note: If you are willing to learn XPath to the depth, then go through the below tutorials. You can come back to read these posts after looking into the list of Chrome extensions.
Here is the table of contents for quickly navigating through the links.
Try 7 Super Useful Chrome Extensions
All these plugins are worth trying, so use them one by one. And then finally decide the winner which is most suitable for you.
1. Find XPath Using XPath Helper Extension
XPath Helper is a Chrome extension that helps you extract, edit, and evaluate XPath queries on any webpage. It’s easy to use and provides a variety of features to help you automate web testing and other tasks.
Features:
- Easily extract XPath queries for any element on a webpage.
- Edit and evaluate XPath queries directly in the extension console.
- View the results of your XPath queries in real-time.
- Move the console to any location on the page to avoid getting in your way.
Instructions:
- Install the XPath Helper extension from the Chrome Web Store.
- Open a new tab and navigate to any webpage.
- Press Ctrl-Shift-X (or Command-Shift-X on Mac) or click the XPath Helper button in the toolbar to open the console.
- Hold down Shift and hover over the element on the page for which you want to extract the XPath query. The XPath query will be displayed in the query box.
- To edit the XPath query, click inside the query box and make your changes. The results box will immediately reflect your changes.
- To evaluate the XPath query, press Enter. The results box will display the elements on the page that match the query.
- To close the console, press Ctrl-Shift-X (or Command-Shift-X on Mac) or click the XPath Helper button in the toolbar again.
Tips:
- To move the console, hold down Shift and then move your mouse over it.
- When rendering HTML tables, Chrome inserts artificial <tbody> tags into the DOM. These tags will consequently show up in queries extracted by the XPath Helper extension.
To add this Chrome extension, click on the below blue button.
2. Find XPath Using SelectorsHub Extension
SelectorsHub is your XPath and CSS selector sidekick. It’s always there to help you find the right selector for the job, whether you’re automating tasks, testing web applications, or just trying to understand how a web page is built.
With SelectorsHub, you can:
- Autogenerate XPath and CSS selectors for any element on a web page
- Verify that your selectors are working as expected
- Use a smart editor to write and edit complex selectors
- Learn about the different types of selectors and how to use them
SelectorsHub is the perfect tool for anyone who works with web pages. It’s easy to use, yet powerful enough to handle even the most complex tasks.
To add the plugin to your browser, click on the blue button.
3. XPath Finder Chrome Extension
It’s by far the simplest of the Chrome plugins to find the XPath. You only need to select the web element that XPath you like to see. You can press <CTRL+C> to copy the XPath from the result box.
To use the XPath Finder extension:
- Click the extension icon to turn the cursor into a crosshair.
- Hover over the element you want to find the XPath for. The element will be highlighted.
- The XPath of the element is displayed in the footer.
To add this in your browser click the green button.
4. Find XPath Using POM Builder Extension
POM Builder is the Chrome extension that helps you find the best locator for any web element, fast. With its smart generation algorithm, POM Builder can automatically suggest locators that are short, reliable, and easy to understand. It can even ignore dynamic IDs generated by some front-end frameworks.
But POM Builder is more than just a locator generator. It also includes a locator tester and a POM code generator. This makes POM Builder a one-stop shop for all your locator needs.
Here’s how to use POM Builder:
- Install the POM Builder extension from the Chrome Web Store or the Microsoft Edge Add-ons store.
- Inspect the web element you want to find a locator for.
- Click the POM Builder icon in the toolbar.
- POM Builder will suggest a locator for the web element.
- Evaluate the suggested locator or customize it to your needs.
- Click the “Generate POM Code” button to generate the corresponding POM code snippet.
- Paste the POM code snippet into your Selenium, Protractor, or TestArchitect project.
Click on the below button to add this plugin to your browser.
5. Find XPath Using Ruto XPath Finder
Ruto is the Chrome extension that gives you the power to find XPath selectors for any web element, fast. With its support for 20+ XPath patterns, dynamic XPath based on parent-child axes, and one-click copying to IDE, Ruto is an essential tool for any test automation engineer.
Why use Ruto?
- Speed and ease: Ruto finds XPath selectors in seconds, so you can spend less time searching and more time testing.
- Reliability: Ruto’s XPath selectors are reliable and work even with dynamic elements.
- Integration: Ruto integrates seamlessly with your test automation framework, making it easy to add XPath selectors to your tests.
How to use Ruto:
- Install the Ruto extension from the Chrome Web Store.
- Inspect the web element you want to find the XPath selector for.
- Click the Ruto icon in the toolbar.
- Ruto will suggest a list of XPath selectors for the web element.
- Select the XPath selector you want to use and copy it to your IDE.
You can click on the below button to add this to your browser.
6. Find XPath Using Selenium Object Finder
Selenium Object Finder (SOF) is a Chrome extension that helps you find and automate Selenium objects on web pages quickly and easily. With SOF, you can see all available id
, name
, and custom attributes
highlighted in different colors, so you can get started with automation right away.
SOF is the perfect tool for Agile test automation engineers. It helps you move fast and stay agile by eliminating the need to search through the DOM for Selenium objects. And because SOF displays the id, name, and custom attribute values while hovering on the colored fields, you can easily ask the application developer to add the necessary attributes for building robust automation test code.
Here’s how to use Selenium Object Finder:
- Install the Selenium Object Finder extension from the Chrome Web Store.
- Navigate to the web page you want to automate.
- Click the Selenium Object Finder icon in the toolbar.
- SOF will highlight all Selenium objects on the page in different colors.
- Hover over a colored field to see the
id
,name
, and customattribute
values. - Use the information displayed by SOF to automate the web page.
Add this plugin to your Chrome by clicking on the below button.
7. Find XPath Using Eskry Chrome Extension
The Sencha Component Locator Chrome extension is your essential companion for automating Sencha Ext JS applications. It helps you easily find and interact with Sencha Ext JS Components by generating a variety of locators for them.
To use the Sencha Component Locator, simply inspect the element on the page that you want to automate. The extension will then suggest a variety of locators for the associated Ext JS Component, including XPath, CSS selector, and Sencha Ext JS-specific locators. You can then use these locators to automate your application using Sencha Test or any other test automation framework.
The Sencha Component Locator also supports Ext JS 4 and above, so you can use it to automate your existing Sencha Ext JS applications as well as new ones.
Try this plugin by clicking on the below green button.
Conclusion
Even Chrome’s core developers would agree that there exist many Chrome extensions that fill the functionality gaps left open by its Dev tools. But just like you can’t use every blade for sharpening your nails, not every plugin would meet your needs.
Hence, we filtered this list of the seven best Chrome extensions to find XPath for Selenium locators and hoped that you would enjoy reading it. Also, we recommend installing and inspecting each of them, so that you can conclude at least with one that suits you the most.
Finally, we accept, and you would agree that it’s not easy to find a high-quality Chrome extension. If you want us to add a Chrome plugin that you know works to find the XPath. Then, do comment and let us know.
Thanks,
TechBeamers