Since we say that IDs are faster and are preferred over XPaths, how different would the execution of the following be?
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It only takes a minute to sign up.Sign up to join this community
When you are looking for an element by id, this is going to eventually come down to
document.getElementById() execution which is blazingly fast and highly optimized by the modern browsers.
XPath location strategy in this case requires traversing the whole HTML tree even though having the id attribute check is usually optimized in XPath engines.