I want to quickly get the class attribute of each WebElementon the page using selenium. I am currently 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 more than thirty seconds on a page with 500 elements. I tried to parallelize the call getAttribute, which is the slowest part of the method, but there was no increase in speed. This makes me think that every call getAttributeretrieves information, rather than saving it locally.
Is there a faster or parallelizable way to do this?
source
share