One of the questions that came during the UI Automation Week was related to performance on using different locators. I remember this arise during the session/experience report of @mwinteringham.
The question, if I remember it correctly, focused on finding elements by “id” vs “css selectors”.
Well, this question in particular kept alive in my head and I want to share with you my findings.
So, I looked at WebDriver specification and also at client side code.
As you can see, basically if you try to find web UI elements by their “id” attribute, the webdriver client library basically changes it to the css selector locator strategy.
Therefore, their performance is essentialy the same.
The same happens with other strategies that are available on client side and that do exist just to make our live easier. However, they will be mapped to the official supported location strategies of the WebDriver specification.
XPath locator strategy is known for being slower and prone to errors (as UI can easily break them).