'How to find the number of elements having the same CSS selector in selenium java?

I am using the latest version of selenium with java.

I am trying to find the number of elements in a certain web page having the same css selector, but I don't want to use findElements(By.cssSelector(CSS)).size() because it takes a significant time to "GET" the elements and then find their count. I don't want to get them, I just need to find their count, i.e. how many elements are in this page having the same CSS value.

Thanks in advance



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source