As mentioned above, you can wait for active connections to close:
private static void WaitForReady() { WebDriverWait wait = new WebDriverWait(webDriver, waitForElement); wait.Until(driver => (bool)((IJavaScriptExecutor)driver).ExecuteScript("return jQuery.active == 0")); }
My observation is unreliable, since data transfer is very fast. Significantly more time is spent on processing and rendering data on the page, and even jQuery.active == 0 data may not yet be displayed on the page.
It is much wiser to use an explicit wait for the element that will be shown on the page, see some answers related to this.
Best of all, if your web application has some kind of custom loader or indicates that the data is being processed. In this case, you can just wait until this indication is hidden.
llatinov Mar 21 '15 at 10:01 2015-03-21 10:01
source share