title: Selenium StaleElementReferenceException explicit wait
body: <p>In my Selenium test code I have a few lines that </p>
  
  <ol>
  <li>Clicks a check box</li>
  <li>Selects an item from a select box</li>
  <li>Clicks a buttom to submit a form</li>
  </ol>
  
  <p>Here is the code</p>
  
  <pre><code>WebElement selectAllElement = driver.findElement(By.id("filterForm:selectAll"));
  if (selectAllElement.isSelected())
  {
      selectAllElement.click();
  }
  
  Select selectLocation = new Select(new WebDriverWait(driver, 30)
      .until(ExpectedConditions
      .presenceOfElementLocated(By.id("filterForm:selectLocation"))));
  
  selectLocation.selectByVisibleText(location);
  
  WebElement filterButton = driver.findElement(By.id("filterForm:filterButton"));
  filterButton.click();
  </code></pre>
  
  <p>I was receiving a <code>StaleElementReferenceException</code> when trying to retrieve the Select element on the page, to try and get around this I added an explicit wait on this element as can be seen in the code above.</p>
  
  <p>I am however still getting a <code>StaleElementReferenceException</code></p>
  
  <p><strong>EDIT (HTML for those elements)</strong></p>
  
  <pre><code>&lt;form id="filterForm" name="filterForm" method="post" action="/UsersJSFMavenApplication/faces/index.xhtml" enctype="application/x-www-form-urlencoded"&gt;
  &lt;input type="hidden" name="filterForm" value="filterForm" /&gt;
  &lt;input id="filterForm:selectAll" type="checkbox" name="filterForm:selectAll" checked="checked" title="allUsers" onclick="mojarra.ab(this,event,'valueChange',0,'filterForm:filterGrid usersForm')" /&gt;All users&lt;table id="filterForm:filterGrid"&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;input id="filterForm:userName" type="text" name="filterForm:userName" disabled="disabled" /&gt;&lt;/td&gt;
  &lt;td&gt;&lt;select id="filterForm:selectLocation" name="filterForm:selectLocation" size="1" disabled="disabled"&gt;   &lt;option value="Keynsham"&gt;Keynsham&lt;/option&gt;
      &lt;option value="London"&gt;London&lt;/option&gt;
      &lt;option value="Silicon Valley"&gt;Silicon Valley&lt;/option&gt;
  &lt;/select&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input id="filterForm:filterButton" type="submit" name="filterForm:filterButton" value="Filter" disabled="disabled" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;input type="hidden" name="javax.faces.ViewState" id="j_id1:javax.faces.ViewState:0" value="-8198231560613594227:-8434387391056535341" autocomplete="off" /&gt;
  &lt;/form&gt;
  </code></pre>