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.