Why does "Default Smart Wait" Stops Working all of the sudden?

Let me tell you my view.

Have a look at an old Q&A about “what Smart Wait actually / internally does”:

@ThanhTo wrote there “Internally, the Smart Wait funcitionality waits for the page to become static within some timeframe”. How the Smart Wait can know if the page has become static?


You can find the source code set of Katalon Studio v8.0.5 at https://github.com/katalon-studio/katalon-studio-testing-framework/blob/master/Include/scripts/groovy/ . You can search for the string “SmartWait” in the set of source codes. There I found nealy 30 hits. Especially the following class is interesting:

I read this, and guess …

When the Smart Wait is enabled, Katalon starts an instance of com.kms.katalon.core.webui.driver.SmartWaitWebDriver which wraps the native org.openqa.selenium.WebDriver. The SmartWaitWebDriver starts a web browser and navigate to a web page; then it injects a small piece of JavaScript like this:

    var callback = arguments[arguments.length - 1].bind(this);
    window.katalonWaiter.katalon_smart_waiter_do_ajax_wait(callback);

and

    var callback = arguments[arguments.length - 1].bind(this);
    window.katalonWaiter.katalon_smart_waiter_do_dom_wait(callback);

These JavaScript code affects to the window object of JavaScript in browser, and let the window to notify the SmartWait object of all of AJAX events and DOM Tree modification events. Effectively Katalon’s SmartWait object will be notified of all AJAX events and DOM Tree modification events in browsers. Provided with this mechanism, the Smart Wait in Katalon can listen to the flow of AJAX events and DOM Tree modification events in the remote browser.

What is AJAX? — See Ajax (programming) - Wikipedia

Provided with the AJAX Event stream is branched and connected, the SmartWait in Katalon Studio can know if the target page is (possibly) still moving somehow/somewhere, or has become static. That is what @ThanhTo told us.

1 Like