CSS selector speed, standard vs Sizzle
This is regarding Selenium 1/RC but somewhat applies to Selenium 2/ WebDriver also.
I was just wondering, if use of specific CSS selectors has any impact on speed performance, primarily for IE but also other browsers. What I'm particularly talking about is using a simple or standard CSS selector vs using a Sizzle-based CSS selector, and long CSS selectors like the following example (even though one can probably simplify the
selector, but let's assume you can't, or you'd have to use XPath if you don't want long CSS selector):
css=div.someService.photoService > div.photoBrowser > div.photoBrowserContainer:nth-child(3) > div.photoBrowserImportBar:nth-child(3) > input[value='import']
I have only started using CSS selectors and just wanted to know whether others use complex or long (Sizzle-based) CSS selectors like example above, and if such selectors have much of a speed improvement over XPath, or if they start to degrade too once the locator string becomes long.
Re: CSS selector speed, standard vs Sizzle
XPath in most cases is the slowest. Selenium will have to build the entire DOM tree.
If you're using a Browser based driver (non HTMLUnit), a handy but quick solution I saw some other company use was jQuery injection. Using executeScript() to run JS code they injected jQuery into the page and use a jQuery selector to return a direct reference to the element's dom selector.