Call a test case and pass variables

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.

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)

2 Likes

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 ?

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

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!

Hey Can you explain this in detail with code example if you have available?

I am trying similar but not having any luck.

So I am trying to do following

There is checkout process and I have created test case for each page lik

  1. Test case A (has 1 variable - var1)
  2. Test case B (has 2 variable - var2, var3, var4)

I am trying to create main Test case and call test Case A and test Case B but I want to pass data into variable from main test case and same for other test case too.

Any suggestion would be helpful.
Thanks

@Mihir_Kadiya
I was having trouble understanding the syntax, but I think this will make more sense:
I have test ParentTest that will call test ChildTest. ParentTest will pass down value ValueToBePassed to ChildTest, who will accept it as VariableInChildTest.

String ValueToBePassed = ‘foobar’
WebUI.openBrowser(‘’)
WebUI.navigateToUrl(‘insertURLhere’)
WebUI.callTestCase(findTestCase(‘ChildTest’), [‘VariableInChildTest’ : ValueToBePassed], FailureHandling.STOP_ON_FAILURE)

Then the ChildTest looks like this:

WebUI.setText(findTestObject(‘SearchBar’), VariableInChildTest)

I tried it out a couple different ways until it clicked. The ValueToBePassed can be a string or its own variable, like I did here, but the parent test wants VariableInChildTest to be presented as a string - don’t forget to put it in single quotes inside the callTestCase function.