How Pass Variable From Test Case A to Test Case B

Hi can advice me on passing the variable from Test Case A (call in test case B) & Test Case B
In below script i have define a variable named ProspectName (highlighted in red).

Then In Test Case B , i tried calling the variable(define in test case A) , seems to be not working, is something wrong with my syntax?

I didn’t call test case B in test case A cause in test case B have other steps that i dont want to run prior finishing test case A.

Any advice on this? Thanks.

1 Like

Hi there, :wave:

Thank you very much for your topic! It may take a little while before Katalon team member or others forum members respond to you.

In the meantime, you can double-check your post to see if you can add any extra information i.e. error logs, HTML codes, screenshots, etc. Check out this posting guide to help us help you better!

Thanks! :sunglasses:
Katalon Community team

Hi @nurainhilmiyabinti.a,

Thank you for sharing your issue. A similar discussion can be found here: Passing Variables Between Testcases - #2 by grylion54. Please try the solution there. Thank you!

Although you are not supposed to need it, you can always put in an explicit “return” statement of your intended result you want to send back to “CreatedProspectName” variable. So, in your calledTestCase(), as the last line you have like below:

WebUI.click(...)
WebUI.click(...)
WebUI.click(...)
return ProspectName

and in your variable, CreatedProspectName, you should have the contents of what you want.

Edit: looking at your code more, I also think you should not be sending “ProspectName” in your parameters, but getting it from your code through the return statement, like I have above. Whatever you send into the calledTestCase will just be overwritten by the “getText” statement (which is what you want), but the variable which you have defined within the code you may be getting a different object as compared to the one in your parameters, even though they have the “same” name.

@nurainhilmiyabinti.a

Screenshots are incovenient for others in the forum to understand your code.

If you want to be advised, please share the whole source code of your Test Case A and Test Case B so that others can copy&paste them into their local machine and try to run them.

If you can not share the source of “Test Case A” and B due to security reason, please create another set of smaller test cases which does not contain any “secure” stuff but can demonstrate your problem (passing values between test cases).

Please use the “Code Formatting Syntax” so that the codes are better presented as follows:


Code fragments enclosed by a pair of triple back ticks makes your code easier for others to read.