code: def wait_for_ajax_calls_to_complete(self, timeout=5):
          
          from selenium.webdriver.support.ui import WebDriverWait
  
          WebDriverWait(self.driver, timeout).until(lambda s: s.execute_script("return jQuery.active === 0"))
docs: Waits until there are no active or pending ajax requests.
  
          Raises TimeoutException should silence not be had.
  
          :param timeout: time to wait for silence (default: 5 seconds)
          :return: None