why "id" is the best way to find the element in selenium webdriver? not xpath? -
why id
best way find element in selenium webdriver? not xpath?
under hood it's doing javascript page search. document.getelementbyid() constant time lookup (o(1)) because there can 1 element per id on page. see answer more in-depth discussion. while on browsers it's not hash map lookup it's still faster xpath (see answer).
see perf test https://jsperf.com/getelementbyid-vs-queryselector/4 comparision.
Comments
Post a Comment