# Create variable can use within a folder of test case or test suite

**URL:** <https://forum.katalon.com/t/create-variable-can-use-within-a-folder-of-test-case-or-test-suite/18077>\
**Category:** Web Testing\
**Tags:** web-testing, katalon-studio\
**Created:** [January 22, 2019, 8:05am UTC](https://forum.katalon.com/t/create-variable-can-use-within-a-folder-of-test-case-or-test-suite/18077 "2019-01-22T08:05:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![cavoidc](https://avatars.discourse-cdn.com/v4/letter/c/f04885/32.png) [@cavoidc](https://forum.katalon.com/u/cavoidc)\
**Post date:** [January 22, 2019, 8:05am UTC](https://forum.katalon.com/t/create-variable-can-use-within-a-folder-of-test-case-or-test-suite/18077/1 "2019-01-22T08:05:34Z")

</div>

I try to create a variable to run only in a folder of the test case, but I can not. Can anyone help me?  
I looking for a solution for the test suite, but not yet.  
Is that possible? Please help me

---

<div class="post-metadata">

**Author:** ![kavyavijaya](https://avatars.discourse-cdn.com/v4/letter/k/ec9cab/32.png) [@kavyavijaya](https://forum.katalon.com/u/kavyavijaya)\
**Post date:** [January 22, 2019, 9:07am UTC](https://forum.katalon.com/t/create-variable-can-use-within-a-folder-of-test-case-or-test-suite/18077/2 "2019-01-22T09:07:10Z")

</div>

Hi  
I am assuming that you are creating a variable in one test case in a folder which contains a set of test cases and trying to access that variable in other test cases in the folder.  
The variable in one test case can be used in other only when it is imported into the test case.  
A variable is private to that test case itself.  
In order to use it call the test case which contains the variable in this testcase.  
Test case 1:  
String a

Test case 2:  
WebUI.callTestCase(findTestCase(‘Test case 1’))

So wherever you want to use the declared variable call the test case 1.  
Regards  
Kavya

---

<div class="post-metadata">

**Author:** ![kostoed](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@kostoed](https://forum.katalon.com/u/kostoed)\
**Post date:** [January 22, 2019, 9:18am UTC](https://forum.katalon.com/t/create-variable-can-use-within-a-folder-of-test-case-or-test-suite/18077/3 "2019-01-22T09:18:22Z")

</div>

> [@cavoidc](#):
>
> I try to create a variable to run only in a folder of the test case, but I can not.

What do you mean? Can’t create?

Maybe like this?

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/7/7fbc629c777cc7bc8f24d811a0a6f7cfff2849a3.png)

---

<div class="post-metadata">

**Author:** ![cavoidc](https://avatars.discourse-cdn.com/v4/letter/c/f04885/32.png) [@cavoidc](https://forum.katalon.com/u/cavoidc)\
**Post date:** [January 22, 2019, 9:31am UTC](https://forum.katalon.com/t/create-variable-can-use-within-a-folder-of-test-case-or-test-suite/18077/4 "2019-01-22T09:31:49Z")

</div>

I create variable in test case A, but can not use in test case B, they in same folder.

---

<div class="post-metadata">

**Author:** ![cavoidc](https://avatars.discourse-cdn.com/v4/letter/c/f04885/32.png) [@cavoidc](https://forum.katalon.com/u/cavoidc)\
**Post date:** [January 22, 2019, 9:47am UTC](https://forum.katalon.com/t/create-variable-can-use-within-a-folder-of-test-case-or-test-suite/18077/5 "2019-01-22T09:47:52Z")

</div>

WebUI.callTestCase(findTestCase(‘User\_Setting/variable’), [(‘variable’) : ‘abcde’], FailureHandling.CONTINUE\_ON\_FAILURE)

print(variable)

But I can not print “variable”

---

<div class="post-metadata">

**Author:** ![ThanhTo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/thanhto/32/697_2.png) [@ThanhTo](https://forum.katalon.com/u/ThanhTo)\
**Post date:** [January 22, 2019, 9:50am UTC](https://forum.katalon.com/t/create-variable-can-use-within-a-folder-of-test-case-or-test-suite/18077/6 "2019-01-22T09:50:32Z")

</div>

Hi @cavoidc

It seems what you’re looking for is a global variable, you can define it in Profile section and call it in the test cae by `GlobalVariable.your_variable_name`

Sharing variables between test cases is what global variables are for.

---

<div class="post-metadata">

**Author:** ![cavoidc](https://avatars.discourse-cdn.com/v4/letter/c/f04885/32.png) [@cavoidc](https://forum.katalon.com/u/cavoidc)\
**Post date:** [January 22, 2019, 10:02am UTC](https://forum.katalon.com/t/create-variable-can-use-within-a-folder-of-test-case-or-test-suite/18077/7 "2019-01-22T10:02:37Z")

</div>

Thanks, bro, but I try to look for a variable can cross test case within test folder.  
Global variable I use for other perpoose

---

<div class="post-metadata">

**Author:** ![Ibus](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@Ibus](https://forum.katalon.com/u/Ibus)\
**Post date:** [January 22, 2019, 11:36am UTC](https://forum.katalon.com/t/create-variable-can-use-within-a-folder-of-test-case-or-test-suite/18077/8 "2019-01-22T11:36:31Z")

</div>

bro, testcases are groovy scripts, read a bit about them:  
[http://groovy-lang.org/structure.html](http://groovy-lang.org/structure.html)

you cannot share variables through folders, but by object scopes …
