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 seven most relevant Chrome Extensions that can help you find XPath in Selenium.
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 which 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 which you master with time.
However, the Chrome browser has a no. 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 which our team has evaluated as the most relevant to find the XPath in Selenium.
Note: If you are willing to learn XPath to the depth, then do 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.
1. XPath Finder Chrome Extension
2. XPath Helper Chrome Extension
3. XPath Helper Wizard Chrome Extension
4. XPather Chrome Extension
5. XML Viewer Chrome Extension
6. Scraper Chrome Extension
7. ENCREO UI Spy Chrome Extension
Try 7 Super Useful Chrome Extensions
All these plugins are worth trying, so use them one by one. And then decide the one which is most suitable for you.
It’s by far the simplest of the Chrome plugins to find the XPath. You only need to select the web element which XPath you like to see. You can press <CTRL+C> to copy the XPath from the result box.
To add this in your browser click the green button.
With this extension, it is easy to form an XPath query. It allows quick editing and evaluation of the queries on any web page. When you click the extension in the Chrome toolbar, it opens a console. You can then utilize the console to write/edit the query and confirm the result in place.
To add this click on the below green button.
It extends the functionality of the previous plugin as it highlights the results with colors. Next, it makes sure to produce short and robust XPath values. With the <CTRL+Shift+X> key combination, you can open the XPath console. And while holding the shift key and hovering it on the target element would fill up the console with the query string to reach the desired XPath. However, you can further fine tune the XPath string.
To add the plugin to your browser, click on the green button.
It’s another reliable Chrome extension to find XPath of the web elements. Also, it automatically evaluates the XPath so don’t worry about any errors. You can use <ALT+X> and <ALT+Shift+X> to toggle the plugin sidebar. It even supports auto-complete feature as you press <ALT+Z>.
Click on the below button to add this plugin in your browser.
An XML viewer by default, but it inherently supports XPath notation and can return XPath on the fly. For calculating XPath, you have to hold CTRL key and hover over the target element. Also, using the shift key, you can select from the multiple XPath values.
You can click on the below button to add this in your browser.
6. Find XPath Using Scraper Chrome Extension
It’s primarily a data mining tool which also uses XPath for web scraping. It integrates with the Chrome context menu as “Scrap similar…” option. So whenever you right-click on a web element, a context menu gets opened. Clicking on the “Scrap similar…” menu option launches another window to show the XPath of the selected element. Please note that it provides limited functionality for XPath search.
Add this plugin in your Chrome by clicking on the below button.
It makes use of open source tools (Webdriver) to find locators. It works in point and capture mode. In addition to the XPath, it can also generate CSS selectors. It’s relatively a new plugin, so do your research and decide if it’s meeting your requirements.
Try this plugin by clicking on the below green button.
Did We Miss Any XPath Finder Chrome Extension?
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 seven best Chrome extensions to find XPath for Selenium locators and hoped that you would have enjoyed reading. Also, we recommend to install and inspect 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 work to find the XPath. Then, do comment and let us know.