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