Personally I would create a String Global Variable and initialize it with the “Parameter filename” in TC 1. Have TC 2 check the file (the value of the Global Variable) and fill the Global Variable in TC 2 (or create 2 Global Variable if you want). Do what you want with the Global Variable’s content in TC 1 to your hearts content. No parameter needed. Just include the import statement at the top of both TCs.
import internal.GlobalVariable as GlobalVariable
If the value that you want to return in not a String, then you will have to go with creating 2 Global Variables.
Maybe like
Here is a simple example of using a String Global Variable to carry the filename around your Test Cases. Sample within TC 1:
GlobalVariable.gFiles = "G:\\Katalon Test Cases\\Data Files\\TestId.xlsx"
WebUI.callTestCase(findTestCase('Miscellaneous/Position'), [], FailureHandling.OPTIONAL)
WebUI.waitForPageLoad(10)
WebUI.delay(2)
WebUI.comment('value is ' + GlobalVariable.gFiles.toString())
Within TC 2, you use the contents of GlobalVariable.gFiles.
def myVar = 'the beginning'
def myMsg = WebUI.callTestCase(findTestCase('Playground/Playful'), ['myKey': myVar], FailureHandling.OPTIONAL)
WebUI.comment('the contents of message is ' + myMsg.toString())
In Test Case 2, you would have: (Note: you would not have to return the same variable from TC 2 that you sent in from TC 1. I did basically so you could see what I was doing.)
Thank you.
GlobalVariable.g_filename = “g_C:\tmp\test\snf_groovy.xml” fails.
I guess I have to find the class GlobalVariable and define my parameter there.
Where is this class located?
Solved it.
I just did the WebUI.callTestCase(findTestCase(… again and the parameter was passed.
Strange behaviour…I wonder what happend if this testcase is used in many place and you need to renew ALL calls…
Returning values works like this
— tescase 1 — int value = WebUI.callTestCase(findTestCase(‘SNF/SNF_00xx/SNF_94_Statement.Transaction.BillingValues.Net.Amount’), [(‘p_filename’) : ‘C:\tmp\test\snf_groovy.xml’
, (‘p_two’) : ‘yyyy’], FailureHandling.STOP_ON_FAILURE)