Skip to content

Latest commit

 

History

History
65 lines (47 loc) · 2.3 KB

File metadata and controls

65 lines (47 loc) · 2.3 KB
title id slug sidebar_label description number hide_table_of_contents level publish_date tags category
CSS vs. Xpath
32-css-vs-xpath
/32-css-vs-xpath
CSS vs. Xpath
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.
32
true
2
2014-01-07
selectors
xpath
css
css selectors
locators
locator strategy
resources

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.

import DisplayTips from '@site/src/components/displayTips';

<DisplayTips languages={[ {label: 'Ruby', value: 'ruby'}, ]}/>

About The Author

Dave Haeffner is the original writer of Elemental Selenium -- a free, once weekly Selenium tip newsletter that's read by thousands of testing professionals. He also created and maintains the-internet (an open-source web app that's perfect for writing automated tests against).

Dave has helped numerous companies successfully implement automated acceptance testing; including The Motley Fool, ManTech International, Sittercity, and Animoto. He is also an active member of the Selenium project and has spoken at numerous conferences and meetups around the world about automated acceptance testing.

Dave Haeffner profile picture