By using site services you agree to our Cookies Use. We and our partners operate globally and use cookies, including for analytics, personalisation, and ads.Accept
X

/How to use an xPath

Xpath is a string that exactly identifies an element on a page. Using the xPath line, you can find the item on the web page.

Each element of a web page can be found using xPath.
Each element of a web page can be found using xPath.

XPath search tools.

Any modern browser, be it IE, Firefox, Chrome, Opera or Safari, allows you to find elements by xPath. You just need to open the developer console and run the following code:

$x(“someXPath”);

You can find detailed instructions on the Internet on this topic.

We recommend using special plugins. Such specialized extensions allow not only a simple search, but also highlight the elements found. Which is very convenient and speeds up the work of a specialist.

An xPath search plugin interfase.
An xPath search plugin interfase.

Recommended plugins:

Chrome

Firefox

Sometimes xPath may vary. This may occur for the following reasons:

You are looking for dynamically loaded content. In such a case the xPath string may be outdated.

The page code for registered user and regular may vary.

The site can be updated, therefore the xPath line will become outdated.

If the item is not found

The xPath string is divided into sections and has a hierarchical structure. This means that each previous section defines an element nested in the previous one.

Each page element is nested inside some other element. In fact, the page consists of squares of different sizes inscribed into each other.
Each page element is nested inside some other element. In fact, the page consists of squares of different sizes inscribed into each other.

If you cannot find the item, delete several sections from the end of the line. So you will find the parent block. This will help you understand the reasons why you can’t looking for by full xPath.

A block with a rating may not be displayed in the first post of search results. Therefore, it makes sense to look for the parent block by deleting several sections from the end of the line.
A block with a rating may not be displayed in the first post of search results. Therefore, it makes sense to look for the parent block by deleting several sections from the end of the line.

As you can see, xPath is a pretty simple thing. Tools for working with it are literally on every personal computer. We hope that the information in this article has helped evaluate all the benefits of this Path Language.

Upgrade your site

Find more than 180 issues on your site.