I'm looking to get the class attribute of every WebElement
on the page quickly with selenium. Currently, I'm doing the following:
allElements = new ArrayList<WebElement>(m_webDriver.findElements(By.cssSelector("*")));
for (WebElement element : allElements) {
String className = element.getAttribute("class");
}
This process is incredibly slow, taking upwards of thirty seconds on a page with 500 elements. I've tried parallelizing the getAttribute
call, which is the slowest part of the method, but there was no speed increase. This leads me to believe that every call to getAttribute
is fetching information instead of storing it locally.
Is there a faster or parallelizable way to do this?