Alternative approaches to Smart Wait for Edge InPrivate

We use Microsoft single sign-on for most of our web applications. This means we need to launch Edge in InPrivate mode so that we’re prompted for username and password (we use a variety of active directory accounts for testing).

Launching Edge in InPrivate mode comes with the significant drawback of not being able to utilise Smart Wait.

Is there any alternative approaches that could be used, besides adding ‘WebUI.waitForElementVisible’, ‘WebUI.waitForElementClickable’ etc. test steps?

To be honest, we find these types of methods fairly flaky for waiting for a webpage to be fully loaded, compared to Smart Wait.

2 Likes

try to open edge in guestmode

options.addArguments(“–guest”)

2 Likes

1. Enhanced Explicit Waits with Fluent Conditions

Instead of generic waitForElementVisible, create custom wait methods that combine multiple conditions for robustness:

// Custom wait for critical elements to be fully interactive
def waitForPageStability(TestObject to, int timeout = 30) {
    WebUI.waitForElementPresent(to, timeout)
    WebUI.waitForElementClickable(to, timeout)
    WebUI.waitForElementNotHasAttribute(to, "disabled", timeout)
}

Usage:
waitForPageStability(findTestObject('LoginPage/btnSubmit'), 45)


2. Page Ready State + Network Idle Detection

Use JavaScript to monitor both DOM readiness and network activity:

groovy

@Keyword
def waitForPageComplete(int timeout = 30) {
    WebDriver driver = DriverFactory.getWebDriver()
    WebUI.waitForCondition(
        { 
            ((JavascriptExecutor) driver).executeScript(
                "return document.readyState === 'complete' && " +
                "window.performance.getEntriesByType('navigation')[0].responseEnd > 0 && " +
                "window.performance.getEntriesByType('resource').filter(r => r.requestStart > (performance.now() - 1000)).length === 0"
            ) == true
        }, 
        timeout
    )
}

Triggers when:

  • DOM is fully loaded
  • No network calls in last 1 second
  • Page rendering is complete

3. Application-Specific Load Triggers

Leverage your app’s unique indicators:

groovy

// Wait for Angular apps
WebUI.waitForAngularLoad(30)

// Wait for React hydration
WebUI.waitForElementHasAttribute(findTestObject('AppRoot'), 'data-hydrated', 30)

// Wait for loader disappearance
WebUI.waitForElementNotPresent(findTestObject('Spinner'), 30)

4. Dynamic Polling with Retry Logic

Implement adaptive waits with exponential backoff:

groovy

@Keyword
def smartWaitForElement(TestObject to, int maxTimeout = 60) {
    int attempts = 0
    int delay = 2
    while (attempts < (maxTimeout/delay)) {
        try {
            WebUI.verifyElementPresent(to, 1)
            return
        } catch (Exception e) {
            sleep(delay * 1000)
            delay = Math.min(delay * 1.5, 5) // Cap at 5s intervals
            attempts++
        }
    }
    throw new Exception("Element not found after ${maxTimeout} seconds")
}

5. Browser-Level Monitoring

Force-enable Smart Wait compatibility via Edge policies (requires admin rights):

  1. Create Registry Key:
    HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Edge\ExtensionSettings
  2. Add policy to allow extensions in InPrivate:

json

{
  "*": {
    "allowed_in_incognito": true,
    "runtime_allowed_hosts": ["*"]
  }
}
  1. Re-launch Edge with --enable-extensions flag in Katalon:

groovy

EdgeOptions options = new EdgeOptions()
options.addArguments("inprivate", "enable-extensions", "load-extension=/path/to/katalon/smartwait")
WebUI.openBrowser('', options)

6. Hybrid Wait Strategy

Combine multiple approaches for maximum reliability:

groovy

def safeInteraction(TestObject to) {
    waitForPageComplete(20)           // JS-level readiness
    waitForPageStability(to, 10)      // Element-specific checks
    WebUI.click(to)                   // Final action
}

Which one was excellent?

Monty’s suggestion?

or any of dineshh’s suggestions?

After a bit more investigation, it doesn’t seem the Smart Wait extension works properly in guest mode. Certain test steps still attempt to execute before the page is fully loaded. The same test scripts work perfectly in a normal browser window (i.e. not using In Private mode).

Bit more information here. As you can see, ‘Extensions’ is disabled in Edge guest mode:

We’re not opposed to using Chrome in incognito mode, and extensions do seem to be enabled in that mode, but we still see flakiness with our tests in this mode: