SmartWait is not working any more

Using Katalon Studio v9.0.0, Chrome v122.0

I happened to see the following incident.

In the “Console” tab of the Chrome DevTools, Chrome emitted several warnings as follows

wait.js:111 [Deprecation] Listener added for a synchronous ‘DOMNodeInserted’ DOM Mutation Event. This event type is deprecated (UI Events) and work is underway to remove it from this browser. Usage of this event listener will cause performance issues today, and represents a risk of future incompatibility. Consider using MutationObserver instead.

To me, this message seems serious. It tells me that the wait.js is not capable to react to any DOM modifications. In short, the Smart Wait is no longer working as expected. Is the Katalon dev team aware of it?


I know that the wait.js is a JavaScript code bundled in all Katalon Studio. I could find the wait.js file at <Katalon Studio installation directory>/configuration/resources/external/Smart Wait/content/wait.js. The wait.js contains the following code fragment:

...
  (function katalon_smart_waiter_do_prewait() {
    window.katalonWaiter = new KatalonWaiter();
    console.log("content script: Katalon Waiter v.2 is up and running !");
    var document = window.document;
    function katalon_smart_waiter_setDOMModifiedTime() {
      window.katalonWaiter.domModifiedTime = Date.now();
    }
    document.addEventListener(
      "DOMNodeInserted",
      katalon_smart_waiter_setDOMModifiedTime,
      false
    );
...

This source + the warning message above makes sense to me.

This is a difficult issue for an outsider. I hope Katalon developer to look at this issue.

@Elly_Tran
@duyluong

1 Like

Hi,

Thank you for letting us know. We will investigate this and let you know soon

@kazurayam Are you saying it’s not working as expected due to the console output or because you see it no longer working?

Reading the error message I understand it as it will break in the future (I plan on resolving it in the Summer) but it has not broken yet. Is that correct?

Regards;
Philip B

Thank you for your response.

Possibly yes, you are right.

I admit that I made a false accusation in the topic title “SmartWait is not working any more”.

I really don’t know how to examine if the SmartWait is working or not.

SmartWait is an enigma to me.

Let me describe what was my original problem before I post this false accusation.


I made a katalon project, published it in a GitHub repository:

In this project, I made a test case script Test Cases/TC0. It visits a public web site of 京都(Kyoto) city.

import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

import internal.GlobalVariable as GlobalVariable

String url = "https://kyoto.travel/en/"

WebUI.callTestCase(findTestCase("sub/visitUrl"), ["tcindex": GlobalVariable.TESTCASE_INDEX, "url": url])

The sub/visitURL is as follows:

...
// navitate to the target URL
WebUI.navigateToUrl(url)

// do somethng on the web page
Path output = Paths.get("./output")
Files.createDirectories(output)
Path screenshot = output.resolve("${timestamp}.${tcindex}.png")
WebUI.takeScreenshot(screenshot.toFile().toString())

// close the borwser
WebUI.closeBrowser()

The sript does a simple thing: open a browser, navigate to an URL, take a screenshot, close the browser window. When I ran the TC0, it always passed silently, but it always took 25 seconds - 35 seconds.

I wondered why this test case takes around 30 seconds?

In my test case script, there is no statement that explicitly determines the processing duration. Therefore I suspected that Katalon Studio controled the duration. But I was not sure what is the factor that controls the duration of around 30 seconds.

I checked the project’s setting :

The Default Page Wait timeout was set to be 60 seconds. This must be irrelevant to my issue.

So what else? I had only one idea: SmartWait may have something to do with this processing duration of 30 seconds. The SmartWait is implemented as a JavaScript. I could find the source on my Mac as follows:

  /Applications/Katalon Studio.app/Contents/Eclipse/configuration/resources/extensions/Chrome/Smart Wait/content:
  drwxr-xr-x@ 4 kazurayam  admin   128  3  6 10:20 .
  drwxr-xr-x@ 5 kazurayam  admin   160 10 24 10:10 ..
  -rwxr-xr-x  1 kazurayam  admin   286  3  6 10:13 wait-injector.js
  -rwxr-xr-x  1 kazurayam  admin  5227  3  6 10:20 wait.js

The wait.js contains an integer value 30000 as a constant:

  KatalonWaiter.prototype.katalon_smart_waiter_do_dom_wait = function(
    callback
  ) {
...
    function katalon_smart_waiter_do_dom_wait() {
      setTimeout(() => {
        const duration = Date.now() - domTime;
        if (domTime && (duration > 30000)) {        // HERE IS THE CONSTANT!
          domTime = "";
          callback(true);
        } else if (
...

I guessed that SmartWait controlls the processing duration of my Test Cases/TC0, which always finishes in 30 secondss.

I hacked the wait.js. I tried changing the constant value from 30000 to 15000, or 30000 to 45000. I saw no effect. I got lost. Then, just accidentally, I noticed a message “wait.js:111 [Deprecation] …”. So I posted the topic “SmartWait is not working any more”. Well, I shouldn’t have done it. I regret it now.


My original question is still open.

Why my Test Cases/TC0 always takes around 30 seconds? How does Katalon Studio control the duration? How can I let TC0 to finish in 15 seconds?

Could someone give me any suggestion?

1 Like

If you change the “Default page load timeout” to “Wait Until the page is loaded” what do you get?

As for the deprecated loading, we’ll be updating that before summer.

Thank you for your response.

I tried it using KS 9.0.0.

With “Default page load timeout” of 60secs, the TC0 took 28secs.

WIth “Wait Until the page is loaded”, the TC0 took 28secs.

I find no difference.