TestProject Forum
Powered by leading experts in the test automation community

findElement vs findElements. much faster?

Assuming i know for sure that only 1 element (unique) is on the page, which is exactly what I’m looking for.

Would it be much of a difference for the WebDriver to find a single element with findElements() method or is the runtime negligible ?

Most of my data is Lists of elements (tables, grids, lists), rarely i need to automate a single element on my page, so it’s easier to refer to single elements as a List in my larger data collection.

findElement will take as long as the timeout period is set to, in some cases it could be up to 30 seconds. Even if it takes just 2-3 seconds to scan the whole page, findElement will still wait to see if JavaScript updates the page.

findElements scans the page only once.

So by using findElements to find one element that you are certain exists, you are wasting time scanning the page after the element was already found.