Looping through with List<WebElement> with Selenium
<p>I get a list of anchors using the code below, and then I want to go to each link. I have came up with the code below, but after the first loop I get the following exception</p>

<blockquote>
  <p>org.openqa.selenium.StaleElementReferenceException: stale element
  reference: element is not attached to the page document   (Session
  info: chrome=55.0.2883.87)</p>
</blockquote>

<pre><code>List&lt;WebElement&gt; listingAnchorList = driver.findElements(By.xpath("//div[contains(@class,'cat')]/a"));

for (WebElement listingAnchor : listingAnchorList) {
    driver.get(listingAnchor.getAttribute("href"));
    System.out.println(driver.getTitle());
}
</code></pre>

<p>Is there anyway to do this without having go to back to the page every time? </p>