0

I need a clarity between cssSelector and Relative Xpaths.
Actually, we are having our Application UI in Angular js in which there are only few locators like cssSelector and Xpaths but not id, names, classes and all etc.
So if we take absolute Xpaths, its changing daily basis whenever developers update designs thats why i used cssSelector but its also not seems to be feasible.
Can anyone let me know what would be the right approach if i use cssSelector or Relative Xpaths because i have to run my scripts in both browser IE all versions as well as Chrome latest version. which locator would be the best and how will i use them as if it changes on daily basis.

chriz
  • 1,339
  • 2
  • 16
  • 32
  • See this answer - http://stackoverflow.com/a/11778665/4720017. There are many questions/blogs debating about XPath vs CSS. – LittlePanda Apr 15 '15 at 11:04
  • possible duplicate of [Which is the best and fastest way to find the element using webdriver? By.XPath or By.ID or anything else? And why?](http://stackoverflow.com/questions/11777694/which-is-the-best-and-fastest-way-to-find-the-element-using-webdriver-by-xpath) – LittlePanda Apr 15 '15 at 11:04
  • I would advise using CSS ById wherever possible. However I have found that (in many Internet Explorer versions) that some CSS-based selectors simply will not work, which forces you into an XPath solution. Yes XPath tends to be slower, but if you're supporting I.E. XPath will likely always work. – Adam T Apr 15 '15 at 15:21

1 Answers1

1

If you are testing on older IE versions, you will find that CSS selectors (even on newer versions) don't play very well with that browser. I would suggest building relative XPath selectors.

aholt
  • 2,829
  • 2
  • 10
  • 13