Which one is better - xpaths or cssSelector? | Selenium Forum
M
Posted on 04/11/2016
Hi,

I have two doubts:
1 Should we use Xpaths or cssSelectors? as hardly there is any difference i observed, but in interviews they put lot of focus on locators questions, please let me know which one is most preferred and why? What are the pros and cons for both ?

2 Suppose on a webpage, once we have already completed automating it, on later stages, developers adds new fields in between the pages, then how to handle this situations, is there any smart way to handle this while automating at first place itself? or later again we need to keep on updating the xpaths?

M
Replied on 08/11/2016

http://elementalselenium.com/tips/32-xpath-vs-css



[quote:2u0g9afk] Suppose on a webpage, once we have already completed automating it, on later stages, developers adds new fields in between the pages, then how to handle this situations, is there any smart way to handle this while automating at first place itself? or later again we need to keep on updating the xpaths?[/quote:2u0g9afk]

no smart way. have to change the xpaths in properties file.