TestProject Forum
Powered by leading experts in the test automation community

Wait for ajax call to complete with Selenium

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 ?


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

WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement element = wait.until(ExpectedConditions.presenceOfElementLocated(By.id("containerDiv")));