Types of Variables


This is a companion discussion topic for the original entry at https://docs.katalon.com/katalon-studio/docs/global-variables.html

Did Katalon removed global variables view? I can not find the Global Variable view icon on the right.
How would I add and review my global variables now?

I’m having trouble finding it also. It’s not there.

I just found out that it is located under Profiles > Default in the Test Explorer pane on the right. You can create global variables there, even though it doesn’t state that. it’s very confusing now.

3 Likes

Yeah, looks like the documentation is out of date.

https://docs.katalon.com/katalon-studio/docs/execution-profile-v54.html

The current Global Variables list now become the Default Profile . There will be NO ‘Global Variables’ interface. You will need to create Global Variables in the new Execution Profile .

2 Likes

Experts please help me. How can I set a global variable during the test case set.
I prefer the verification way.

Thank you.

GlobalVariable.nameOfGlobalVariableGoesHere

parameterize Global Variables in http body directly not working it not picking the actual global variable value.

Turns out they change Katalon GlobalVariables without fixing the documentation.

Can you set a Global Variable from a script?

Edit: Found out that you can but it only persists it during the test case/test suite execution session.

GlobalVariable.foo = "bar"

Today I did the same experience. Did you find any solution to set persistent variables? Does somebody has any idea?

1 Like

Hello, does anyone know the syntax for using variables defined in the variables tab in execute Javascript? I’ve tried many variations but nothing I’ve tried works…

WebUI.executeJavaScript('document.getElementsByName(‘j_domain’)[0].value = ‘+${GlobalVariable.vVar}+’:wink:
WebUI.executeJavaScript('document.getElementsByName(‘j_domain’)[0].value = ‘+${vVar}+’;
WebUI.executeJavaScript('document.getElementsByName(‘j_domain’)[0].value = ‘+vVar+’;
WebUI.executeJavaScript('document.getElementsByName(‘j_domain’)[0].value = ‘+GlobalVariable.vVar+’;

THANKS!

Please refer to this tutorial.

I have a global variable that I set in one of my test suite and I want to use it in my next test suite in my test suit collection.

When I run my test suite collection in the second test suite of the collection the global variable is empty? how can I fix that, a global variable should be global through out my run…??? the collection I ran is in sequential, one suite is in Chrome and the other is in Android… I can’t put all the test cases in the same test suite.

@jtheoret

A GlobalVariable.X is scoped for a single test suite run. Test cases in a Test Suite can share the value of GlobalVariable.X. But Test Suite A and Test Suite B can not share the dynamically updated value of GlobalVariable.X. GlobalVariable is designed as such. You can not change this behavior.

If you want to pass information across multiple test suites, you should create a file and write/read info for yourself.

Test Case a1 in the Test Suite A creates a file and save the value into it; Test Case b1 in the Test Suite B reads the file and consume info in it. You can employ any format for the file. If I were you, I would employ JSON format as Groovy language supports JSON natively. Please have a look at my previous post for a sample code:

Or you can use a Excel file. See the following previous post of mine:

This post is titled “multiple test cases in a test suite can share a excel file”. But more precisely in fact “multiple test cases in multiple Test Suites can share a excel file”.

Or simply you can use the Excel keyword plugin:
https://store.katalon.com/product/34/Excel-Keywords

@jtheoret

Test Suite A and Test Suite B are supposed to be independent each other. This is how Test Suite concept is designed

This implies, your Test Suite B depends on the the previous Test Suite A. Then I think you should not group your test cases as test suites. I would rather recommend you to use “Controller TestCase pattern” implemented using WebUI.callTestCases() keyword. See the following post:

Test Suite - Script Mode - set up method - how to pass common data value - #5 by kazurayam