@world.absorb
def wait_for_ajax_complete():
 javascript = '\n        var callback = arguments[arguments.length - 1];\n        if(!window.jQuery) {callback(false);}\n        var intervalID = setInterval(function() {\n          if(jQuery.active == 0) {\n            clearInterval(intervalID);\n            callback(true);\n          }\n        }, 100);\n    '
 for _ in range(5):
  try:
   result = world.browser.driver.execute_async_script(dedent(javascript))
  except WebDriverException as wde:
   if ('document unloaded while waiting for result' in wde.msg):
    world.wait(1)
    continue
   else:
    raise
  return result

@ world . absorb def wait_for_ajax_complete ( ) : javascript = '\n        var callback = arguments[arguments.length - 1];\n        if(!window.jQuery) {callback(false);}\n        var intervalID = setInterval(function() {\n          if(jQuery.active == 0) {\n            clearInterval(intervalID);\n            callback(true);\n          }\n        }, 100);\n    ' for _ in range ( 5 ) : try : result = world . browser . driver . execute_async_script ( dedent ( javascript ) ) except WebDriverException as wde : if ( 'document unloaded while waiting for result' in wde . msg ) : world . wait ( 1 ) continue else : raise return result
wait until all jquery ajax calls have completed .