XPath is a language used for selecting specific part of a XML document. It’s really useful when, for instance, we use tools like Selenium and we need to select a particular element on a web page.
In this article I’m going to present a really simple app that allows us to get an XPath selector without effort.
Installing and Using ChroPath
ChroPath is an addon compatible with the most used browsers in the world. It simplifies a lot the way how we get the XPath selector of any web component.
In order to install it, open the official page and download the version for your browser.
Once installed, let’s see how to use it.
The example has been done using Chrome browser. Some commands might be different if you are using a different browser.
Let’ say that we wish to develope an application using Selenium that has to open a web browser, reach the Google home page and search news about weather report.
In order to do that we need to get the XPath selector for the Google query text box, so let’s open the Google home and right click on the query text box than select the Inspect menù:
You’d notice now that on the right there is a window with some tools. Click on the >> icon so that you can reach the ChroPath menù:
You can get the same result pressing F12. This command is compatible with any browsers.
At this stage you can see the XPath selector for the query text box selected at the beginning:
As you can see the selector value is:
Leave A Comment