Skip to main content

CSS vs. XPath

NOTE: This is part 1 of 3. For the second installment, go here. For the last installment, go here.

Intro​

One of the most heated and subjective conversations in the Selenium community is which locator strategy is better, often circling around two -- XPath and CSS. People in favor of CSS say that it is more readable and faster (especially when running against Internet Explorer). While those in favor of XPath tout its ability to transverse the page (while CSS cannot).

With such a divide, it can be hard to determine the best approach for you and your team. Especially when most of these claims are outdated.

A Solution​

Let's cut through the noise by running our own performance tests across all major browsers to see how CSS and XPath stack up and fall down. Then we will be able to determine a more helpful locator strategy.

Authors​

Dave Piacente
Original creator of Elemental Selenium
Diego Molina
Elemental Selenium maintainer