Sunday 7 October 2012

Selenium Selectors XPath or CSS which one is your favourite?

Hey Guys,

If you people have ever written any selenium scripts, you must be aware of XPath and CSS selectors. They are the most used selectors in Selenium especially XPath. There are other selectors like ID,Class Name, Name, Link Text though exist and you can use them but XPath and CSS gives you an edge while finding an element in  complex HTML structure. Ok so which one is better? XPath or CSS????

In my experience so far, I have used XPath selectors/locators in selenium but in recent times they are my last options to use, Yes I mean, I prefer CSS before XPath. Reason is very simple, XPath is slow. I do write all my tests for IE browser and IE does not support XPath natively and it is damn slow in IE. But as I said, It is my last option that mean, i know when no other selectors finds me an element, XPath is the saviour.

Here I am posting a video by Sauce which is showing  a comparison between XPath and CSS, a really nice video to watch.


Watch the video, and share your experiences with XPath and CSS selectors in Selenium also. Please give your valuable comments to improve the blog. 

Thanks!!

3 comments:

  1. Great ! This is indeed helpful. As a tool for automation testing Selenium, CSS locators work better than XPath Locator, because of compatibility.

    ReplyDelete
  2. This is not related with Selenium locators.
    Would like to know which framework is better JUnit or TestNG?
    Can we have TestNG framework on Windows 7?

    ReplyDelete
    Replies
    1. TestNG is much better than JUnit in terms of features but JUnit4 added some good features also.These frameworks are not dependent upon OS, TestNG should work on Windows 7.

      Delete

Related Posts

Related Posts...