I cannot, I don’t use Katalon Studio, but here’s a sample using a Java method. You should be able to copy paste this somewhere and have it work out of box:
/**
* Uses a MutationObserver (JavaScript) to wait for the DOM to stop changing. "Changing" can include addition/removal/modification of ANY elements in the DOM
*/
public static void waitForDomModifications() {
JavascriptExecutor javascriptExecutor = JavaScriptUtil.getJavascriptExecutor();
javascriptExecutor.executeScript("if(typeof observer === 'undefined') { window.domModifiedTime = Date.now(); var targetNode = document.querySelector('body'); var config = { attributes: true, childList: true, subtree: true }; var callback = () => { window.domModifiedTime = Date.now(); }; var observer = new MutationObserver(callback); observer.observe(targetNode, config); }");
long modifiedTime = 0;
long start = System.currentTimeMillis();
while (modifiedTime != (long) javascriptExecutor.executeScript("return window.domModifiedTime") && System.currentTimeMillis() - start < 30000) {
modifiedTime = (long) javascriptExecutor.executeScript("return window.domModifiedTime");
_wait(300);
}
}
You’ll just need to get a JavascriptExecutor instance from the Katalon libs, however that is done. I have a 300 ms “polling” rate with the _wait(300);, you’d have to use WebUI.delay() probably.