How to import an existing test case into another test case

I have 2 test cases and I want to use one test case variable value in another test case. The variable is defined under variables tab but I am calculating that variable value during the script.

Now I want to use this calculated value in another test. Is it possible in Katalon?

You can use ‘return’ statement to return its value from one test case and then use it in another test case, e.g:


def returnedValue = WebUI.getText(...)
return returnedValue

Main TC:

def textFromTC1 = WebUI.callTC(findTestCase('TC1'),[:]))
assert textFromTC1 == expectedText

Thanks a lot!

Hi Nguyen ,

can you share us the Manual view for the above said one . We are also faceing the same problem.
To return more than one value for calling test case to Main test case .

I am also facing same problem… I have test case 1, Test case2.

I wanted to use the outcome of a variable in test case 2. Return statement is not allowing more than one variable to return. How to use variable from one test case to other test case.

Nguyen/Bhawna Rani, Can you please share us Manual View.

You could using return Map to return several variables value

**Test Case 1: **

Map Map_TC1 = [:]
return Map_TC1

**Test Case 2: **

Map TC_1_called = WebUI.callTestCase(findTestCase("TC_1"), [:])
println TC_1_called['TC1_Var1']
println TC_1_called['TC1_Var2']


String u = WebUI.getAttribute(findTestObject(‘SignInPage/txt_username’), ‘placeholder’)

WebUI.setText(findTestObject(‘SignInPage/txt_username’), username)

String p = WebUI.getAttribute(findTestObject(‘SignInPage/txt_password’), ‘placeholder’)


WebUI.setText(findTestObject(‘SignInPage/txt_password’), password)‘SignInPage/btn_signinButton’))

Map Map_TC1 = [:]



return Map_TC1;

**TC2: **

Map TC_1_called = WebUI.callTestCase(findTestCase(‘01_UserManagement/Login’), [(‘username’) : ‘Anna’, (‘password’) : ‘Analyst_2017’,(‘inlinetextofusername’):’’,(‘inlinetextofpassword’):’’], FailureHandling.STOP_ON_FAILURE)



**Log: **

12-11-2017 04:31:40 PM - [START] - Start action : Statement - Map_TC1 = [:]

12-11-2017 04:31:40 PM - [END] - End action : Statement - Map_TC1 = [:]

12-11-2017 04:31:40 PM - [START] - Start action : Statement - Map_TC1.put(“inlinetextofusername”, u)

12-11-2017 04:31:40 PM - [END] - End action : Statement - Map_TC1.put(“inlinetextofusername”, u)

12-11-2017 04:31:40 PM - [START] - Start action : Statement - Map_TC1.put(“inlinetextofpassword”, p)

12-11-2017 04:31:40 PM - [END] - End action : Statement - Map_TC1.put(“inlinetextofpassword”, p)

12-11-2017 04:31:40 PM - [START] - Start action : Statement - return Map_TC1

12-11-2017 04:31:40 PM - [END] - End action : Statement - return Map_TC1

12-11-2017 04:31:40 PM - [ERROR] - Test Cases/01_UserManagement/Logout FAILED because (of) Variable ‘inlinetextofusername’ is not defined for test case.

12-11-2017 04:31:41 PM - [END] - End Test Case : Test Cases/01_UserManagement/Logout

can you please correct me the usage?

nhi> Thanks for the answer. Can you please let me know the usage by seeing script?

Any update from any one?

@“Chandrasekaran Ganapathy”: You are missing quotation marks in below scripts:


They should be:


Thanks for the reply… I got it working by passing that map values.

Map TC_1_called = WebUI.callTestCase(findTestCase(‘01_UserManagement/Login’), [(‘username’) : ‘Anna’, (‘password’) : ‘Analyst_2017’,(‘Map_TC1’):’’], FailureHandling.STOP_ON_FAILURE)

My question was: Is there any possibility to extend my test case to another test case like in Selenium we can extend a class to another class and all the variables and methods can be access because I don’t want to call the whole test and execute, I just want to have access to the variables to use their value in my current test case because I am calculating a value and pass them to variable.

One possibility is to combine these two test cases and make it one. With this option test case becomes too long and can’t be reused in other test cases.

make use of CustomeKeywords.

Thanks Mohammad

I have TC1 and LoginTC. LoginTC is called from TC1. During the call, i want to pass the Username and Password from TC1 to LoginTC.

Q1. Should i send those as a Map?
Q2. In LoginTC, how do i call these map entries ?

So i did something like


[(‘Password’) : ‘X’, (‘Username’) : ‘A’],


LoginTC: _To access the map values _
WebUI.setText(findTestObject(‘input_LoginTextField’), Username )
WebUI.setText(findTestObject(‘input_PasswordTextField’), Password )

So, Is this the correct way (test case is working) or is there a better way?

Finally, I found answer here on how to use a particular variable from one test case in another test case without executing the whole test case.