title: Selenium StaleElementException after refilling in form after submission
body: <p>I have a form that I am trying to automate filling in for one of my Selenium scripts. There is a form that has about 4 text fields of which the HTML looks like this</p>
  
  <pre><code>&lt;input class="class" id="id" name="name" value="" autocomplete="off" wtx-context="stuff" type="text"&gt;
  </code></pre>
  
  <p>Then after filling those forms, there is an input submit button with the following HTML code</p>
  
  <pre><code>&lt;input id="id2" class="class2" value="Add Material" wtx-context="morestuff" type="submit"&gt;
  </code></pre>
  
  <p>I have used the following Java code and am successful in getting the forms to be filled in and submitted, but once they are submitted, I assume what is happening is they are refreshed on the DOM and then I get a StaleElement exception thrown at me. I've kind of hacked my way around it by going to the homepage and navigating my way back to the webpage with the form, but I'm looking for a more elegant solution if anyone knows one. Below is my Java code.</p>
  
  <pre><code>Page.WriteToField(Page.Input_number(), "111111111");
  Page.WriteToField(Page.Input_number2(), "222222222");
  Page.WriteToField(Page.Input_date(), format.format(cal.getTime()));
  Page.WriteToField(Page.Input_number3(), "3333");
  Page.SubmitIngredient();
  </code></pre>
  
  <p>The WriteToField() function looks this</p>
  
  <pre><code>public void WriteToField(WebElement field, String text) {
      field.click();
      field.clear();
      field.sendKeys(text);
  }
  </code></pre>
  
  <p>And I access all of the WebElements from my page classes using the following format</p>
  
  <pre><code>public WebElement Input_number() {
          return wait.until(ExpectedConditions.elementToBeClickable(By.id("form1")));
  }
  </code></pre>