What exactly is "Default wait for element timeout (in seconds) " (in the Settings) and how exactly does it work?

Hi,

What exactly is “Default wait for element timeout (in seconds)” (in the Settings) and how exactly does it work?

Is this exactly the same as ImplicitWait in Selenium? For example, if it’s set to 10 seconds, would Katalon wait for the PRESENCE of the element for UP TO 10 seconds (CHECKING for its presence every 500 milliseconds)? Thanks.

As per https://docs.katalon.com/katalon-studio/docs/execution-settings.html#default-execution-settings,

Default wait for element timeout : The default timeout period (in seconds) that Katalon Studio waits for the application under test to be loaded when executing automation test.

but it’s not clear how exactly it works.

As far as I know, you are correct in your assumption: it is the same as an implicit wait in selenium. I believe the default is 30 seconds. The main purpose however is to provide a default timeout for WebUI methods that do not take an explicit timeout argument, such as WebUI.click().

Thank you Brandon.

The main reason for my question was to make sure that if “Default wait for element timeout (in seconds)” is set to 10 seconds (for example), Katalon will be checking for its presence (for example, every 500 millisecond) and if the element is available after 2 seconds (for example) of waiting, Katalon WILL NOT be waiting 8 more seconds. That’s how ImplicitWait works in Selenium. If it = 10 seconds, it will wait UP TO 10 seconds (though some people don’t know this and think that Selenium will be waiting EXACTLY 10 second)

This is correct. And I agree, the wording of that setting isn’t very clear. Ideally, it should say something like “Default maximum wait for element timeout (in seconds)”. At the end of the day, that’s what a timeout essentially is, but I can see where that might be confusing.

1 Like

Could someone tell me where this valued is stored? Is it in the .prj file or somewhere else?
Thank you

In every Katalon projects there is a file:

<projectDir>/settings/internal/com.kms.katalon.execution.properties

Open this properties file, you will find a line:

execution.default.timeout=30

This is the place where the Default wait for element timeout (in secods)" is stored.

I could edit the execution.default.time of a Katalon project manually,

closed and reopened the project in Katalon Studio GUI, I saw the new value is acknowledged by Katalon Studio.

Is it possible to change the timeout value runtime programatically using Katalon’s API after your Katalon project has launched?

No, it is not supported. The com.kms.katalon.core.configuration.RunConfiguration class wraps the properties. The class does not implement a method

void setTimeout(int seconds).

I presume, this is by design. Katalon does not think that a user ever wants to change the timeout value on the fly. They do provide a GUI to author the properites, so it should be enough.

Let me reply to the question raised by the original poster:

Katalon does NOT use the implicitWait of Selenium WebDriver. Katalon implements a logic of wait on its own.

In the source code com.kms.katalon.core.webui.common.WebUiCommonHelper class, you can find a method findElementByNormalMethod:

    /**
     * Find Web Elements by using Attributes, XPath or CSS locators
     */
    private static FindElementsResult findElementByNormalMethods(TestObject testObject, SelectorMethod locatorMethod,
            int timeout) {
        WebDriver webDriver = DriverFactory.getWebDriver();

        By defaultLocator = buildLocator(testObject, locatorMethod);
        if (defaultLocator == null) {
            throw new StepFailedException(MessageFormat.format(
                    StringConstants.KW_EXC_WEB_ELEMENT_W_ID_DOES_NOT_HAVE_SATISFY_PROP, testObject.getObjectId()));
        }

        logger.logDebug(MessageFormat.format(StringConstants.KW_LOG_INFO_FINDING_WEB_ELEMENT_W_ID,
                testObject.getObjectId(), defaultLocator.toString(), timeout));

        List<WebElement> foundElements = Collections.emptyList();

        long startTime = System.currentTimeMillis();
        do {
            try {
                foundElements = webDriver.findElements(defaultLocator);
                if (foundElements != null && !foundElements.isEmpty()) {
                    logger.logDebug(MessageFormat.format(StringConstants.KW_LOG_INFO_FINDING_WEB_ELEMENT_W_ID_SUCCESS,
                            foundElements.size(), testObject.getObjectId(), defaultLocator.toString(), timeout));
                    break;
                }
            } catch (NoSuchElementException e) {
                // not found element yet, moving on
            }
        } while ((System.currentTimeMillis() - startTime) / 1000 <= timeout);

        if (foundElements == null || foundElements.isEmpty()) {
            logger.logInfo(MessageFormat.format(StringConstants.KW_LOG_INFO_CANNOT_FIND_WEB_ELEMENT_BY_LOCATOR,
                    defaultLocator.toString()));
            return FindElementsResult.from(getSelectorValue(testObject, locatorMethod), locatorMethod);
        }

        return FindElementsResult.from(foundElements, getSelectorValue(testObject, locatorMethod), locatorMethod);
    }

Here you can see a fragment:

    long startTime = System.currentTimeMillis();
    do {
        ...
    } while ((System.currentTimeMillis() - startIme) / 1000 <= timeout);

This is Katalon’s implementation of wait for XXXX.


Yes, it does.

Effectively, Katalon’s do { .... } while (...) achieves something quite similar to the implicitWait in Selenium.


No. This is not the way Katalon took. See the program source code to see how it is implemented.