My tests are crawling because of "Ghost" popups

I’m trying to run my full regression suite, but it’s taking hours to finish. The main reason is that my app sometimes shows a “Newsletter Signup” or a “Survey” popup, and sometimes it doesn’t.

I added a step to click the “Close” button on the popup just in case it appears. But on the days the popup doesn’t show up, Katalon just sits there staring at the screen for 30 seconds before it finally gives up and moves to the next step. I tried setting the timeout to 1 in the WebUI.click command, but it still feels like it’s taking way too long, and sometimes the whole test fails as “FAILED” just because that one optional button wasn’t there. How do I tell Katalon to “check quickly, and if it’s not there, just keep going without making a big deal out of it?”

“Ghost” popups slow tests—use if exists → close, else continue (1s timeout).

One-Liner Fix

if (WebUI.verifyElementPresent(popup_CloseBtn, 1, FailureHandling.OPTIONAL)) {
    WebUI.click(popup_CloseBtn)
}

1s check max—no popup = instant skip, no failure.

Keyword (Reusable)

@Keyword
void dismissIfExists(TestObject closeBtn) {
    if (WebUI.verifyElementClickable(closeBtn, 1, FailureHandling.OPTIONAL)) {
        WebUI.click(closeBtn)
        println 'Popup dismissed'
    } else {
        println 'No popup'
    }
}

Add to every test start: CustomKeywords.dismissIfExists(Newsletter_Close)

Suite Setting: Execution > Delay Between Actions: 0ms (global speedup)

What you’re experiencing is the “Implicit Wait” trap combined with strict failure handling. By default, if a Test Object isn’t found, Katalon waits for the global timeout and then logs a failure.

In professional architecture, we handle these as Optional Elements. We use two specific strategies to keep the suite fast:

  1. Short-Circuit Timeouts: Overriding the 30-second wait for that specific check.

  2. Failure Handling: Using OPTIONAL or CONTINUE_ON_FAILURE so the test status doesn’t turn red just because a marketing popup didn’t appear.

The Solution: The “Check and Clear” Pattern

Instead of just trying to click, we use verifyElementPresent with a very short timeout (e.g., 2-3 seconds) and a boolean check.

Custom Keyword Helper: The Popup Buster

This keyword will quickly check for an element. If it finds it, it clicks it; if not, it exits in under 2 seconds without failing your test.

import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.model.FailureHandling

class SpeedHelper {

    /**
     * Attempts to close an optional popup quickly without slowing down the suite
     * @param to The Test Object of the 'Close' button or popup
     * @param timeoutInSeconds How long to wait before giving up (default 2s)
     */
    @Keyword
    def closeOptionalElement(TestObject to, int timeoutInSeconds = 2) {
        // We use STOP_ON_FAILURE = false (FailureHandling.OPTIONAL) 
        // to ensure the test continues even if the element isn't found
        boolean isPresent = WebUI.verifyElementPresent(to, timeoutInSeconds, FailureHandling.OPTIONAL)
        
        if (isPresent) {
            WebUI.click(to)
            println "Optional popup cleared."
        } else {
            println "No popup detected, skipping..."
        }
    }
}

How to use it in your Script:

Place this at the start of your test or wherever the popup usually interrupts the flow:

CustomKeywords.'SpeedHelper.closeOptionalElement'(findTestObject('Object Repository/btn_ClosePopup'), 2)

hi @rhowell

try to use verifyElementPresent with FailureHandling.OPTIONAL and a short timeout instead of click. The OPTIONAL failure handling is what prevents the step from failing your test when the element is absent. The short timeout is what prevents the long wait.

if (WebUI.verifyElementPresent(findTestObject('btn_ClosePopup'), 1, FailureHandling.OPTIONAL)) {
    WebUI.click(findTestObject('btn_ClosePopup'))
}

when the popup is absent, Katalon checks for 1 second, gets a false return, and moves on without logging a failure. When it is present, the condition is true and the click executes. Drop this into a custom keyword if you want to reuse it across tests without repeating the logic.

@rhowell did you try sugegestions?

Hello,
You can handle optional popups in Katalon by using WebUI.verifyElementPresent or WebUI.waitForElementClickable with a very short timeout, then wrapping the click in an if condition. That way, if the ConcoraCard element isn’t found quickly, the test just skips the step instead of waiting or failing.

Best regards,
Ivy Cordes

Any of the above suggested solutions worked for you?

Whether the issue got resolved?