Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>CSS selectors perform far better than Xpath and it is well documented in Selenium community. Here are some reasons,</p> <ul> <li>Xpath engines are different in each browser, hence make them inconsistent</li> <li>IE does not have a native xpath engine, therefore selenium injects its own xpath engine for compatibility of its API. Hence we lose the advantage of using native browser features that WebDriver inherently promotes.</li> <li>Xpath tend to become complex and hence make hard to read in my opinion</li> </ul> <p>However there are some situations where, you need to use xpath, for example, searching for a parent element or searching element by its text (I wouldn't recommend the later).</p> <p>You can read blog from Simon <a href="http://old.eurostarconferences.com/blog/2013/1/28/liveblogged!-automated-web-testing-traps-for-the-unwary-with-simon-stewart">here</a> . He also recommends CSS over Xpath.</p> <p>If you are testing content then do not use selectors that are dependent on the content of the elements. That will be a maintenance nightmare for every locale. Try talking with developers and use techniques that they used to externalize the text in the application, like dictionaries or resource bundles etc. Here is my <a href="http://nileshdk.wordpress.com/2013/08/06/internationalization-automating-localized-ui-using-selenium-webdriver/">blog</a> that explains it in detail.</p> <h2>edit 1</h2> <p>Thanks to @parishodak, here is the <a href="http://elementalselenium.com/tips/34-xpath-vs-css-revisited-2">link</a> which provides the numbers proving that CSS performance is better</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload