Wait for ajax call to complete with Selenium

  • 1 Replies
  • 987 Views
Wait for ajax call to complete with Selenium
« on: May 04, 2016, 20:00:59 pm »
I'm running tests in selenium on a UI that uses Ajax calls.

Is is possible to make the driver wait until the ajax call can complete ?

e.g.:
Code
WebElement button = driver.findElement(By.xpath("//button[contains(@class, 'ui-button')]"));

button.click();   //clicking the button triggers ajax call that will fill div with html content

Assert.isNotEmpty(driver.findElement(By.Id("containerDiv")).Text);

*

Ruhit

  • *
  • 22
Re: Wait for ajax call to complete with Selenium
« Reply #1 on: May 08, 2016, 18:08:02 pm »
Code
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement element = wait.until(ExpectedConditions.presenceOfElementLocated(By.id("containerDiv")));

 

Sitemap 1 2 3 4 5 6 7 8