Russ Thomas said:
Guys,
This is a fundamental part of Katalon’s testing API – it certainly works so there must be some issue in your code if it doesn’t work.
First of all, let’s set up a global variable called THE_ANSWER with the value “42” and, let’s do this in “TestCase 1”
GlobalVariable.THE_ANSWER = "42"
Now, in “TestCase 2”, let’s print its value using a comment:
WebUI.comment("The answer is ... " + GlobalVariable.THE_ANSWER)
Now execute a suite that runs “TestCase 1” before “TestCase 2”
If that doesn’t work, check to see if the GlobalVariable component is imported correctly – you should see this line in your import section at the top of the file:
import internal.GlobalVariable as GlobalVariable
If it STILL doesn’t work, well… something terrible is wrong with your system Reinstall?
Hope this helped.
Russ
Hi Russ, first of all thanks for your response. I have created a sample project and following is the set up, I am still getting the error as shown below.
TestCase1 :
import internal.GlobalVariable as GlobalVariable
GlobalVariable.THE_ANSWER = “42”
TestCase2:
import internal.GlobalVariable as GlobalVariable
WebUI.comment("The answer is … " + GlobalVariable.THE_ANSWER)
TestSuite - SampleTest:
1. TestCase1
2. TestCase2
Following are the Console messages I am seeing.
04-18-2018 12:26:25 PM - [START] - Start Test Suite : Test Suites/SampleTest
04-18-2018 12:26:25 PM - [RUN_DATA] - Logging run data ‘hostName’ with value ‘nabhaskar - USBLRNABHASKAR1.us.deloitte.com’
04-18-2018 12:26:25 PM - [RUN_DATA] - Logging run data ‘os’ with value ‘Windows 10 64bit’
04-18-2018 12:26:25 PM - [RUN_DATA] - Logging run data ‘hostAddress’ with value ‘10.31.112.166’
04-18-2018 12:26:25 PM - [RUN_DATA] - Logging run data ‘katalonVersion’ with value ‘5.4.0.1’
04-18-2018 12:26:26 PM - [START] - Start Test Case : Test Cases/TestCase1
04-18-2018 12:26:26 PM - [INFO] - Evaluating variables for test case
04-18-2018 12:26:26 PM - [START] - Start action : Statement - THE_ANSWER = “42”
04-18-2018 12:26:26 PM - [END] - End action : Statement - THE_ANSWER = “42”
04-18-2018 12:26:26 PM - [ERROR] - Test Cases/TestCase1 FAILED because (of) Variable ‘THE_ANSWER’ is not defined for test case.
04-18-2018 12:26:26 PM - [END] - End Test Case : Test Cases/TestCase1
04-18-2018 12:26:26 PM - [START] - Start Test Case : Test Cases/TestCase2
04-18-2018 12:26:26 PM - [INFO] - Evaluating variables for test case
04-18-2018 12:26:27 PM - [START] - Start action : comment
04-18-2018 12:26:27 PM - [END] - End action : comment
04-18-2018 12:26:27 PM - [ERROR] - Test Cases/TestCase2 FAILED because (of) Variable ‘THE_ANSWER’ is not defined for test case.
04-18-2018 12:26:27 PM - [END] - End Test Case : Test Cases/TestCase2
04-18-2018 12:26:27 PM - [END] - End Test Suite : Test Suites/SampleTest
Any help would be greatly appreciated, thanks.