Call and Pass variable to another test case

I want to call a test case and pass a variable of type webdriver and extenttest and his values to another testcase but i don’t have type “other” in the list of type and i can’t pass the value

Hi @rahmaa

You can wrap your object (whatever it is) in a list, and then create a variable in your Test Case that’s of type List.

The test case being called

import yourpackage.MyObject as MyObject
// extent is defined in variable tab as type List
if (extent.size() > 0) {
    MyObject myObject = extent.get(0)


The caller test case

import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase

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

import yourpackage.MyObject

MyObject myCustomObject = new MyObject("This is created in the caller test case");

WebUI.callTestCase(findTestCase("New Test Case"), ["extent": Arrays.asList(myCustomObject)])

When you execute the caller test case, you will get:

2019-09-24 16:45:09.986 WARN  c.k.katalon.core.logging.KeywordLogger   - Please use "KeywordUtil.logInfo()" instead of "new KeywordLogger()" constructor. "KeywordLogger" is an internal API and might be changed in the future.
2019-09-24 16:45:10.114 DEBUG testcase.Caller Test Case                - 1: myCustomObject = new yourpackage.MyObject(This is created in the caller test case)
2019-09-24 16:45:10.119 DEBUG testcase.Caller Test Case                - 2: callTestCase(findTestCase("New Test Case"), ["extent":Arrays.asList(myCustomObject)])
2019-09-24 16:45:10.348 INFO  c.k.katalon.core.main.TestCaseExecutor   - --------------------
2019-09-24 16:45:10.348 INFO  c.k.katalon.core.main.TestCaseExecutor   - CALL Test Cases/New Test Case
2019-09-24 16:45:10.358 INFO  c.k.katalon.core.main.TestCaseExecutor   - extent = [yourpackage.MyObject@495fac5f]
2019-09-24 16:45:10.382 DEBUG testcase.New Test Case                   - 1: if (extent.size() > 0)
2019-09-24 16:45:10.387 DEBUG testcase.New Test Case                   - 1: myObject = extent.get(0)
2019-09-24 16:45:10.388 DEBUG testcase.New Test Case                   - 2: println(myObject.getValue())
This is created in the caller test case
2019-09-24 16:45:10.393 INFO  c.k.katalon.core.main.TestCaseExecutor   - END CALL Test Cases/New Test Case
2019-09-24 16:45:10.393 INFO  c.k.katalon.core.main.TestCaseExecutor   - --------------------

Which means your custom MyObject (it’s just a class with method getValue) is passed successfully in the test case being called.

Cheers !


it works , thanks a lot

Hello @ThanhTo
I am using Manual steps in Katalon and want to do the same and it is very hard to follow the solution, I tried to edit the script but don’t know what should replace in my code exactly.