7 Comments

Something I don’t know though: Assuming I’m using a version of Selenium that supports CSS selectors, is there anything I can do with XPath that CSS can’t do?

March 27, 2008 at 6:29 am

Alex Chaffee says:

Yes, XPath is more powerful and there are a few things you can do with it that you can’t with CSS Selectors. Most notably, CSS is lacking a [parent selector](http://www.andybudd.com/archives/2006/01/what_i_want_from_css3_part_2/) and since on this particular gig I’m layering tests on top of an existing app it’s easier for me to use XPath’s “..” than to go in and change the app to put an id on the parent.

But you should definitely consider using CSS Selectors since their syntax is clearer and more concise for the 95% of real-world cases you will actually encounter, assuming your HTML is peppered with enough unique _id_ or _class_ attributes to cut down on the XPath spaghetti.

April 1, 2008 at 9:00 pm

Anwarul Kabir says:

Hi

Can some one point to me some documents on using CSS query with Selenium IDE. I am currently using xpath to do the test but my team lead want me to change it and use css selectors. So I am looking for some document that will show me the step by step process…

Hey, I haven’t really been pushing this and it’s been a while since I worked on it, but I did develop a library for doing CSS selections on arbitrary XML documents. I’m pretty sure I’ve implemented all of the CSS3 selectors. About the only thing that I haven’t done yet is any kind of performance tuning or optimizations. But I’d be interested in feedback.