To identify errors in AJAX using your JavaScript error handler and then setting a global JavaScript flag variable is a useful technique. This allows you to access any JavaScript variables in Selenium. For instance, you can implement a function like the following to wait 10 seconds and check if a JavaScript variable has been set to true:
def check_javascript_status(browser):
"""Verify if the key JavaScript flag is indicating that all jQuery functions are operational."""
timeout = time.time() + 10
while time.time() < timeout:
flag = browser.evaluate_script("window.javascriptReady == true")
if flag:
return
time.sleep(0.1)
raise AssertionError("The window.javascriptReady JS flag was not received")