Skip to content

Instantly share code, notes, and snippets.

@angelovstanton
Created February 28, 2016 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelovstanton/74ee474eca2daa2f0f41 to your computer and use it in GitHub Desktop.
Save angelovstanton/74ee474eca2daa2f0f41 to your computer and use it in GitHub Desktop.
public void WaitForAjaxComplete(int maxSeconds)
{
bool isAjaxCallComplete = false;
for (int i = 1; i <= maxSeconds; i++)
{
isAjaxCallComplete = (bool)((IJavaScriptExecutor)driver).
ExecuteScript("return window.jQuery != undefined && jQuery.active == 0");
if (isAjaxCallComplete)
{
return;
}
Thread.Sleep(1000);
}
throw new Exception(string.Format("Timed out after {0} seconds", maxSeconds));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment