actionDelay property

I’m trying to retrieve the actionDelay property from the run configuration:

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.configuration.RunConfiguration as RC
def executionProfile = RC.getExecutionProfile()
WebUI.comment("Execution Profile = ${executionProfile}")
def actionDelay = RC.getProperty('actionDelay')
WebUI.comment("Action Delay = ${actionDelay}")
def projectDir = RC.getProjectDir()
WebUI.comment("Project Directory = ${projectDir}")

And it outputs as null.

But, its in the output if I just do:

WebUI.comment("Complete Execution Properties: " + RC.getExecutionProperties().toString())

However, I don’t want the users of the output to have to wade through that entire list for one value.

Any suggestions would be greatly appreciated.

You need to read the source code of the RunConfiguration class at https://github.com/katalon-studio/katalon-studio-testing-framework/blob/master/Include/scripts/groovy/com/kms/katalon/core/configuration/RunConfiguration.java to find out how to appropriately get access to “actionDelay”.

The following code possibly does what you want.

import com.kms.katalon.core.configuration.RunConfiguration as RC
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import groovy.json.JsonOutput

Map<String, Object> execution_property = RC.getProperty(RC.EXECUTION_PROPERTY)
println "execution_property: " + JsonOutput.prettyPrint(JsonOutput.toJson(execution_property))

Map<String, Object> general = execution_property.get("general")
println "general: " + JsonOutput.prettyPrint(JsonOutput.toJson(general))

String actionDelay = general.get("actionDelay")
WebUI.comment("actionDelay: " + actionDelay)

When I ran this I got the following output in the console:

2021-03-04 10:43:19.557 INFO  c.k.katalon.core.main.TestCaseExecutor   - --------------------
2021-03-04 10:43:19.563 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/TC7
2021-03-04 10:43:20.711 DEBUG testcase.TC7                             - 1: execution_property = getProperty(EXECUTION_PROPERTY)
2021-03-04 10:43:20.714 DEBUG testcase.TC7                             - 2: println("execution_property: " + JsonOutput.prettyPrint(JsonOutput.toJson(execution_property)))
execution_property: {
    "general": {
        "autoApplyNeighborXpaths": false,
        "ignorePageLoadTimeoutException": false,
        "timeCapsuleEnabled": false,
        "executionProfile": "default",
        "excludeKeywords": [
            "verifyElementPresent",
            "verifyElementNotPresent"
        ],
        "xpathsPriority": [
            {
                "left": "xpath:attributes",
                "right": true
            },
            {
                "left": "xpath:idRelative",
                "right": true
            },
            {
                "left": "dom:name",
                "right": true
            },
            {
                "left": "xpath:link",
                "right": true
            },
            {
                "left": "xpath:neighbor",
                "right": true
            },
            {
                "left": "xpath:href",
                "right": true
            },
            {
                "left": "xpath:img",
                "right": true
            },
            {
                "left": "xpath:position",
                "right": true
            }
        ],
        "timeout": 30.0,
        "actionDelay": 2.0,
        "methodsPriorityOrder": [
            {
                "left": "XPATH",
                "right": true
            },
            {
                "left": "BASIC",
                "right": true
            },
            {
                "left": "CSS",
                "right": true
            },
            {
                "left": "IMAGE",
                "right": true
            }
        ],
        "proxy": "{\"proxyOption\":\"NO_PROXY\",\"proxyServerType\":\"HTTP\",\"username\":\"\",\"password\":\"\",\"proxyServerAddress\":\"\",\"proxyServerPort\":0,\"exceptionList\":\"\",\"applyToDesiredCapabilities\":true}",
        "defaultFailureHandling": "STOP_ON_FAILURE",
        "terminateDriverAfterTestCase": false,
        "defaultPageLoadTimeout": 30.0,
        "report": {
            "videoRecorderOption": {
                "enable": false,
                "useBrowserRecorder": true,
                "videoFormat": "AVI",
                "videoQuality": "LOW",
                "recordAllTestCases": false,
                "allowedRecordIfFailed": true,
                "allowedRecordIfPassed": false
            },
            "screenCaptureOption": true,
            "reportFolder": "/var/folders/7m/lm7d6nx51kj0kbtnsskz6r3m0000gn/T/Katalon/Test Cases/TC7/20210304_104316"
        },
        "enablePageLoadTimeout": false,
        "terminateDriverAfterTestSuite": true,
        "useActionDelayInSecond": "SECONDS",
        "testDataInfo": {
            
        },
        "selfHealingEnabled": false
    },
    "drivers": {
        "system": {
            "WebUI": {
                "chromeDriverPath": "/Applications/Katalon Studio.app/Contents/Eclipse/configuration/resources/drivers/chromedriver_mac/chromedriver",
                "browserType": "CHROME_DRIVER"
            }
        },
        "preferences": {
            "WebUI": {
                
            }
        }
    },
    "globalSmartWaitEnabled": true,
    "logTestSteps": true,
    "current_testcase": "Test Cases/TC7"
}
2021-03-04 10:43:20.796 DEBUG testcase.TC7                             - 3: general = execution_property.get("general")
2021-03-04 10:43:20.830 DEBUG testcase.TC7                             - 4: println("general: " + JsonOutput.prettyPrint(JsonOutput.toJson(general)))
general: {
    "autoApplyNeighborXpaths": false,
    "ignorePageLoadTimeoutException": false,
    "timeCapsuleEnabled": false,
    "executionProfile": "default",
    "excludeKeywords": [
        "verifyElementPresent",
        "verifyElementNotPresent"
    ],
    "xpathsPriority": [
        {
            "left": "xpath:attributes",
            "right": true
        },
        {
            "left": "xpath:idRelative",
            "right": true
        },
        {
            "left": "dom:name",
            "right": true
        },
        {
            "left": "xpath:link",
            "right": true
        },
        {
            "left": "xpath:neighbor",
            "right": true
        },
        {
            "left": "xpath:href",
            "right": true
        },
        {
            "left": "xpath:img",
            "right": true
        },
        {
            "left": "xpath:position",
            "right": true
        }
    ],
    "timeout": 30.0,
    "actionDelay": 2.0,
    "methodsPriorityOrder": [
        {
            "left": "XPATH",
            "right": true
        },
        {
            "left": "BASIC",
            "right": true
        },
        {
            "left": "CSS",
            "right": true
        },
        {
            "left": "IMAGE",
            "right": true
        }
    ],
    "proxy": "{\"proxyOption\":\"NO_PROXY\",\"proxyServerType\":\"HTTP\",\"username\":\"\",\"password\":\"\",\"proxyServerAddress\":\"\",\"proxyServerPort\":0,\"exceptionList\":\"\",\"applyToDesiredCapabilities\":true}",
    "defaultFailureHandling": "STOP_ON_FAILURE",
    "terminateDriverAfterTestCase": false,
    "defaultPageLoadTimeout": 30.0,
    "report": {
        "videoRecorderOption": {
            "enable": false,
            "useBrowserRecorder": true,
            "videoFormat": "AVI",
            "videoQuality": "LOW",
            "recordAllTestCases": false,
            "allowedRecordIfFailed": true,
            "allowedRecordIfPassed": false
        },
        "screenCaptureOption": true,
        "reportFolder": "/var/folders/7m/lm7d6nx51kj0kbtnsskz6r3m0000gn/T/Katalon/Test Cases/TC7/20210304_104316"
    },
    "enablePageLoadTimeout": false,
    "terminateDriverAfterTestSuite": true,
    "useActionDelayInSecond": "SECONDS",
    "testDataInfo": {
        
    },
    "selfHealingEnabled": false
}
2021-03-04 10:43:20.842 DEBUG testcase.TC7                             - 5: actionDelay = general.get("actionDelay")
2021-03-04 10:43:20.845 DEBUG testcase.TC7                             - 6: comment("actionDelay: " + actionDelay)
2021-03-04 10:43:21.035 INFO  c.k.k.c.keyword.builtin.CommentKeyword   - actionDelay: 2.0
2021-03-04 10:43:21.049 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/TC7

Please find the result:

actionDelay: 2.0

That’s actually even better than what I ended up doing:

def actionDelay = RC.getExecutionProperties().general.actionDelay
String actionDelayTimeScale = 
    RC.getExecutionProperties().general.useActionDelayInSecond.toString().toLowerCase()
WebUI.comment("Action Delay = ${actionDelay} ${actionDelayTimeScale}")

Thanks for the reply. I ended up just outputting the whole thing in a test case so it would be part of the test suite collection report.