Call a test case and pass variables


#1

Hi,
I have two test cases, and I want to pass a variable from one to another
I tried to apply this tutoriel: https://docs.katalon.com/display/KD/Call+test+case

So, in the first test Case, I call the second test case:
WebUI.callTestCase ( findTestCase(‘Repertoire/Comm_Case’), [site : site_web, num : tel], FailureHandling.STOP_ON_FAILURE)

site and num are Global Variables that I created and initiated with " ",
and site_web and tel are the two variables that i want to pass to the second test case

Please tell me how should I initiate my Global Variable, and how should I call and use the variables site_web and tel in the second test case.

Thank you.


#2

Problem solved.
I should put site and num between quotes, and they should be local variables in the called test case, as String, init=" "
There is no need to Global Variable.
WebUI.callTestCase ( findTestCase(‘Repertoire/Comm_Case’), [‘site’ : site_web, ‘num’ : tel], FailureHandling.STOP_ON_FAILURE)


#3

Wijdane said:

Problem solved.
I should put site and num between quotes, and they should be local variables in the called test case, as String, init=" "
There is no need to Global Variable.
WebUI.callTestCase ( findTestCase(‘Repertoire/Comm_Case’), [‘site’ : site_web, ‘num’ : tel], FailureHandling.STOP_ON_FAILURE)

I have same problem but question is how to use ‘site’ and ‘num’ in Comm_Case TestCase
you are use those passed variables somewhere in Comm_Case ?
if yes then how ?


#4

I have issue on passing variable that has a random value to another test case.

Solution: I created a Global Variable with empty string then I set that Global Variable on my testCase_1 with a random value. I can now call that Global Variable to my testCase_2 without calling testCase_1. But you must execute testCase_1 first on your test suite.

testCase_1:
GlobalVariable.randomString = yourRandomValue

testCase_2:
String variableFromTestCase_1 = GlobalVariable.randomString

Screen Shot 2018-11-08 at 5.54.31 PM.png


#5

Hello,

I have a specific test where I need to check if the ‘Amount’ values of a given customer is same in 2 different web applications. My approach is as follows -

  1. Connect to App1 and exact few customer IDs and their corresponding ‘Amount’ field values. Save it somewhere in the form of a table / excel file or concatenate the two fields and store as one variable.
  2. Connect to App2 and exact customer IDs and corresponding amounts of the same customers and save it in the same format as above.
  3. Check if the amount values of App1 are matching with that of App2 for every customer.

I read through many blogs but did not come across any feature to compare two files/values which contains values generated during test execution.
Could someone advise me on this please, or if there are other workarounds that I could try.

Many thanks in advance for your time and help!