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

**URL:** <https://forum.katalon.com/t/why-does-default-smart-wait-stops-working-all-of-the-sudden/87016>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [April 13, 2023, 11:48pm UTC](https://forum.katalon.com/t/why-does-default-smart-wait-stops-working-all-of-the-sudden/87016 "2023-04-13T23:48:49Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [April 14, 2023, 11:54pm UTC](https://forum.katalon.com/t/why-does-default-smart-wait-stops-working-all-of-the-sudden/87016/7 "2023-04-14T23:54:07Z")

</div>

> [@david.avalos](#):
>
> Clearly the “smart wait” is waiting for something to happen/finish. I did look for documentation on the matter but I only found that it “Automatically waits for front-end processes”. It really isn’t giving me anything to work with.

Let me tell you my view.

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

> [@\[WebUI\] Smart Wait Function](http://forum.katalon.com/t/webui-smart-wait-function/32816/3):
>
> Hi @kazurayam The setting in Project \> Setting \> Execution for Smart Wait will take effect for all test cases. While if you disable the global setting, and use the smart wait enable/disable keywords in your test case, then only the section of code between these two keywords will be affected by the smart wait functionality. Internally, the Smart Wait functionality waits for the page to become static within some timeframe, so that the phenomenon where elements are not present, or some loading ov…

@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/](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:

> <https://github.com/katalon-studio/katalon-studio-testing-framework/blob/master/Include/scripts/groovy/com/kms/katalon/core/webui/common/internal/SmartWait.java>

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:

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

```

and

```auto
    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](https://en.wikipedia.org/wiki/Ajax_(programming))

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.

---

_[View the full topic](https://forum.katalon.com/t/why-does-default-smart-wait-stops-working-all-of-the-sudden/87016)._
