Search code examples
katalon-studio

Logging the steps of a custom keyword method in Katalon Studio


Context

We run across the same widgets on multiple pages, and oftentimes cover multiple scenarios for a given page on the site under test. This and other concerns has motivated me to move the page action concerns to GeneralWebUIUtils and page objects, respectively, in the Keywords.

Example

For example, we have this class GeneralWebUIUtils, defined to be:

package com.xxx.utils

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

public final class GeneralWebUIUtils {
    //...

    public static void HandleAutoComplete(TestObject textField, String input, TestObject loader, TestObject firstDropdownOption) {
        WebUI.click(textField)

        WebUI.setText(textField, input)

        WebUI.waitForElementVisible(loader, 3)

        WebUI.waitForElementNotVisible(loader, 3)

        WebUI.waitForElementNotPresent(firstDropdownOption, 3)

        WebUI.waitForElementVisible(firstDropdownOption, 3)

        WebUI.click(firstDropdownOption)
    }
}

In one test case in particular, I have to handle autocomplete, for which I'll use GeneralWebUIUtils.HandleAutoComplete from this class.

OK, now what's the issue?

I am now facing performance issue from that method, and before that, a stale element exception. Typical test case issues, just moved to a package. Whenever I check out the log viewer, it doesn't show the steps of that method like it would if that method existed on the test case itself:

enter image description here

This is problematic because it means you can't check out the logs to find out what is going on, let alone what is creating the bottleneck. You are therefore forced to use the debug mode, which is prone to problems of its own (think forced waiting, and b/c of that, flaky debug sessions).

How can we tell Katalon to log the different WebUI keywords like it does in the local-to-test-case version of this method?


Solution

  • For logging from custom keywords, you can use KeywordUtil.logInfo() method, as described in documentation.

    For more info, you can check the Katalon forum.