質問

Asking for your help because I'm get stuck.

In my autotests based on Selenium WebDriver + Java I using this construction for checking that there is no background AJAX connections:

private boolean hasNoActiveConnections() {
    return (Boolean) ((JavascriptExecutor) browser.getDriver()).executeScript("return $.active == 0");
}

But at some pages of WebApplication $.active returning 1 or more (2, 3, 4,...) even if there is realy no background connections and all requests are received response (checked it in FireBug). I can't change code of application, I'm only autotests developer.

Is there way to getting number of active AJAX connection except of $.active jQuery global property? Maybe on pure JavaScript or on WebDriver?

Thanks for your help and sorry for my english.

役に立ちましたか?

解決

According to the ticket:

JQUERY.ACTIVE IS NOT DECREMENTED ON COMPLETION OF AJAX REQUEST IF AN EXCEPTION OCCURS IN ANY DEFERRED.DONE/FAIL CALLBACKS

So $.active is the right way to check the number of active connections. It just highlights that some ajax requests are failed when $.active remains not equal to zero.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top