title: Selenium wait for AJAX request to finish after button click
body: <p>When I finish filling out a form, and click the submit button, I am trying to wait until the call returns before checking to see if the inserted data appears in my view.</p>
  
  <p>I am trying to figure out how to get this working.  When looking at the page markup, it will refresh the view.  Is there a way for me to do something like:  <em>Wait until children of WebElement change?</em></p>
  
  <p>I was thinking I could just sit at the views parent and just monitor for a change in children before searching for the inserted data.</p>
  
  <p>I was not sure if <code>WebDriverWait</code> accomplishes that task by setting up some sort of listener on the parent <code>WebElement</code>.</p>
  
  <p>Here is some code I have been working with:</p>
  
  <pre><code>public WebElement getWebElement(String selector){
    return (new WebDriverWait(driver,5000))
      .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(selector)));
  }
  
  public submitButton(){
    WebElement submit = getWebElement("#mybutton");
    WebElement gridDataParent = getWebElement("#myTable &gt; tbody");
  
    //Not quite sure how to check for child changes, and start a listener here
  
    submit.click();
  
  }
  </code></pre>
  
  <p>I think there has to be some way in which I could monitor for changes under a given root, no?</p>
  
  <p>After the button submits, it will do a server call and after the call would refresh the dataset.</p>