# How to use parameters between testcases

**URL:** <https://forum.katalon.com/t/how-to-use-parameters-between-testcases/55793>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [June 16, 2021, 4:35pm UTC](https://forum.katalon.com/t/how-to-use-parameters-between-testcases/55793 "2021-06-16T16:35:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jherrmann.extern](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/jherrmann.extern/32/16103_2.png) [@jherrmann.extern](https://forum.katalon.com/u/jherrmann.extern)\
**Post date:** [June 16, 2021, 4:35pm UTC](https://forum.katalon.com/t/how-to-use-parameters-between-testcases/55793/1 "2021-06-16T16:35:12Z")

</div>

Hi,  
I work complete with the backend. No GUI or browsers at all.  
I searched a lot but did nt get my missing link

TestCase 1 should call TestCase 2 and send Parameter filename.  
Testcase 2 should check the file and return a value

I tried a lot and I guess it would be the best to start from scratch.  
Has anybody a simple example or some code snippets?

Thx Jochen Herrmann

---

<div class="post-metadata">

**Author:** ![grylion54](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/grylion54/32/16265_2.png) [@grylion54](https://forum.katalon.com/u/grylion54)\
**Post date:** [June 16, 2021, 5:40pm UTC](https://forum.katalon.com/t/how-to-use-parameters-between-testcases/55793/2 "2021-06-16T17:40:29Z")

</div>

Personally I would create a **String** Global Variable and initialize it with the “Parameter filename” in TC 1. Have TC 2 check the file (the value of the Global Variable) and fill the Global Variable in TC 2 (or create 2 Global Variable if you want). Do what you want with the Global Variable’s content in TC 1 to your hearts content. No parameter needed. Just include the import statement at the top of both TCs.

`import internal.GlobalVariable as GlobalVariable`

If the value that you want to return in not a String, then you will have to go with creating 2 Global Variables.

> **Maybe like**
>
> Here is a simple example of using a String Global Variable to carry the filename around your Test Cases. Sample within TC 1:
> 
> ```auto
> GlobalVariable.gFiles = "G:\\Katalon Test Cases\\Data Files\\TestId.xlsx"
> 
> WebUI.callTestCase(findTestCase('Miscellaneous/Position'), [], FailureHandling.OPTIONAL)
> WebUI.waitForPageLoad(10)
> WebUI.delay(2)
> 
> WebUI.comment('value is ' + GlobalVariable.gFiles.toString())
> 
> ```
> 
> Within TC 2, you use the contents of GlobalVariable.gFiles.
> 
> ```auto
> def filename = GlobalVariable.gFiles.toString().split{"/")[4]
> 
> ```

If you want to go with a String parameter.

> **Using a String parameter**
>
> In Test Case 1
> 
> ```auto
> def myVar = 'the beginning'
> def myMsg = WebUI.callTestCase(findTestCase('Playground/Playful'), ['myKey': myVar], FailureHandling.OPTIONAL)
> 
> WebUI.comment('the contents of message is ' + myMsg.toString())
> 
> ```
> 
> In Test Case 2, you would have: (Note: you would **not** have to return the **same** variable from TC 2 that you sent in from TC 1. I did basically so you could see what I was doing.)
> 
> ```auto
> myKey = "the end"
> 
> return (myKey)
> 
> ```

---

<div class="post-metadata">

**Author:** ![jherrmann.extern](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/jherrmann.extern/32/16103_2.png) [@jherrmann.extern](https://forum.katalon.com/u/jherrmann.extern)\
**Post date:** [June 17, 2021, 8:12am UTC](https://forum.katalon.com/t/how-to-use-parameters-between-testcases/55793/3 "2021-06-17T08:12:52Z")

</div>

Thank you.  
GlobalVariable.g\_filename = “g\_C:\tmp\test\snf\_groovy.xml” fails.  
I guess I have to find the class GlobalVariable and define my parameter there.  
Where is this class located?

---

<div class="post-metadata">

**Author:** ![jherrmann.extern](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/jherrmann.extern/32/16103_2.png) [@jherrmann.extern](https://forum.katalon.com/u/jherrmann.extern)\
**Post date:** [June 17, 2021, 8:14am UTC](https://forum.katalon.com/t/how-to-use-parameters-between-testcases/55793/4 "2021-06-17T08:14:47Z")

</div>

Thank you, but I guess global Variable asr not really the way I would prefer.  
I tried to pass p\_filename

WebUI.callTestCase(findTestCase(‘SNF/SNF\_00xx/SNF\_94\_Statement.Transaction.BillingValues.Net.Amount’), [(‘p\_filename’) : ‘C:\tmp\test\snf\_groovy.xml’],  
FailureHandling.STOP\_ON\_FAILURE)

* * *

## In Testcase SNF\_94\_Statement.Transaction.BillingValues.Net.Amount I defined a parameter ![image](https://europe1.discourse-cdn.com/katalon/original/3X/8/4/84924370f25d2afad4277b402ac260e16b83c53d.png)

and I use this parameter like this:  
 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/8/e/8e6c119136cdee76f072d6440459669f279451cf.png)  
(I wonder why p\_filename is underlined)

but the debugging says that p\_filename is “”

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/0/5/0501fa114942cdc83d0df49c040a8b7f1d8d496f.png)

---

<div class="post-metadata">

**Author:** ![jherrmann.extern](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/jherrmann.extern/32/16103_2.png) [@jherrmann.extern](https://forum.katalon.com/u/jherrmann.extern)\
**Post date:** [June 17, 2021, 8:49am UTC](https://forum.katalon.com/t/how-to-use-parameters-between-testcases/55793/5 "2021-06-17T08:49:29Z")

</div>

Solved it.  
I just did the WebUI.callTestCase(findTestCase(… again and the parameter was passed.  
Strange behaviour…I wonder what happend if this testcase is used in many place and you need to renew ALL calls…

Returning values works like this  
— tescase 1 —  
**int value =** WebUI.callTestCase(findTestCase(‘SNF/SNF\_00xx/SNF\_94\_Statement.Transaction.BillingValues.Net.Amount’), [(‘p\_filename’) : ‘C:\tmp\test\snf\_groovy.xml’  
, (‘p\_two’) : ‘yyyy’], FailureHandling.STOP\_ON\_FAILURE)

println “${value}”  
— testcase 2 ----  
return 300

---

<div class="post-metadata">

**Author:** ![grylion54](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/grylion54/32/16265_2.png) [@grylion54](https://forum.katalon.com/u/grylion54)\
**Post date:** [June 17, 2021, 3:02pm UTC](https://forum.katalon.com/t/how-to-use-parameters-between-testcases/55793/6 "2021-06-17T15:02:49Z")

</div>

Global Variables are defined/created under Profile (bottom of the list of Test Explorer).

[https://docs.katalon.com/katalon-studio/docs/execution-profile-v54.html](https://docs.katalon.com/katalon-studio/docs/execution-profile-v54.html)

There is also a great post by Brandon\_Hein about passing parameters between test cases:

> [@How to pass variables between test cases in a suite (the "right" way...)](http://forum.katalon.com/t/how-to-pass-variables-between-test-cases-in-a-suite-the-right-way/40745):
>
> Hey all, I would just like to share a super simple approach to passing variables between test cases in a suite, as I’ve seen many topics over the years with questions on how to do this efficiently. To be clear, there are already several approaches to this, including, but not limited to: 1.) Creating “empty” GlobalVariables in a Profile, assigning values to those variables at runtime, then consuming them as a global variable in later scripts. This approach works fine, but in my opinion is non…
