Skip to content

How to wait all ajax requests finished except “ ==0”?

In fact, I’am working in webdriver, I want to make it to wait ajax finished. following is the code I got from searched websites:

public static void waitAjaxDone(WebDriver dr) {
    WebDriverWait wait = new WebDriverWait(dr, 60);
    wait.until(new ExpectedCondition<Object>() {
        public Object apply(@Nullable WebDriver webDriver) {
            return ((JavascriptExecutor)webDriver).executeScript("return");


we could see that the key code is “”, this may got the running ajax request count, but it now works for me, and my websites did not use jQuery but other js library.

is there other way to get the count of running ajax ? or is there a matched method in pure javascript to the “” ?


In fact, It is really hard to know whether the ajax requests is done, we could to send the ajax reqeust directly to get the response , then do the next steps