title: Selenium WebDriver access a sub element
body: <p>I have a <code>div</code> with a unique ID. Under that <code>div</code> are a bunch of <code>span</code> elements that have <code>className=foo</code>.  There are  several <code>span</code> elements with <code>className=foo</code> but they are unique to each <code>div</code> (if that's clear).  So my Selenium code first gets the unique <code>div</code> as a web element then tries to take that element and get by class name the <code>span</code> like so </p>
  
  <pre><code>element = sDriver.findElement(By.id("c_"+cID)); 
  String sTest = element.findElement(By.className("actions")).getText();
  </code></pre>
  
  <p>On the second line it throws an exception every time</p>
  
  <pre><code>org.openqa.selenium.StaleElementReferenceException: Element not found in the cache - perhaps the page has changed since it was looked up
  Command duration or timeout: 22 milliseconds
  </code></pre>
  
  <p>Do I misunderstand how to get that <code>span</code> from under a unique <code>div</code>?</p>