Efficient FindElement - xPath\ID\Name – what would be the best practice

Hello,

Refer to Webapp\Hybrid application, a question which keeps coming is what would be the most efficient way to find an element.
I’ve been told that using xpath is the worst way while using ID\Name is better.

What if I use an absolute path to an element (to reduce search time) ?
How does appium finds an element by ID\Name – does it keep some kind of a live dictionary (otherwise it still needs to search the DOM tree).

Thanks!

@Erezinho there will be no issue if you are using the XPath(same as the web page) for the Webapp\Hybrid application.Its better to use the relative XPath instead of absolute.

So ‘find by id’ and ‘find by name’ are preferred on ‘find by xpath’ only in case of Native app ?

I’m still trying to understand if there is a fundamental difference in the way each ‘find’ approach is implemented…
I believe it is not a ‘simple’ search in the DOM and has some heuristics/optimizations

Any documentation about how the search is actually being performed ?