Can we pass a value generated in a test case to another test case as a input ??

Hi All,

I have come across a situation where , in a test case , i will be creating a name which is going to be the input for the nexttest case.

In detail :

  1. Test case  A : This test case is to schedule an audit... I have to schedule an audit by giving Unique  " Audit name " each and every time.

Note : Audit name will be randomly generated with the help of script. ( I am not passing the" audit name" value from a data file or as a Global variable )

  1. Test Case B : In this test case... i need to map an audit to the auditor based on the  "Audit name " created in the Test case A.
  2. I cannot call the "Test case A " in "Test case B " because "Close browser " is the  last step in Test Case A. When the execution of A gets finished automatically the browser will close it stopping me from pass the " Audit name" from A to B.

I have so many scenarios like the above.

SO .. I am in need of help from the community to resolve this.

Please help me out of this.

Let me know for further clarifications.

Guys any solutions ????

Thanks & Regards

Sridhar S






  • I maybe wrong, but i think you can save the Audit name generated in Test Case A as a Global Variable in the Script mode of the same test case. Use that Global Variable in Test Case B as an input. Do give it a try. Thanks.
  • Hey Prithviraj,

    Firs of all thanks for your response.

    Sure .. let me check and come back :)


  • Hey Prithiv,

    I am sorry to say as unfortunately your solution did not help me to solve my problem.

    Anyways thanks for your help.

    Let us wait and see for other solution ..Hope solutions from others would really help both of us :)


    Sridhar S
  • Hi there,

    Actually you can have a 'return' statement in test case A and then use it in test case B:



    String testString = 'abcdef'

    return testString


    String returnString = WebUI.callTestCase('TC_A')

    println returnString

    The results when executing TC_B will print 'abcdef' for returnString. So you can ultilize the 'return' statement and map it in your test case B per your scenario.

  • Hi Vinh Nguyen,

    Thanks for your reply. I tried with the below but it is not working as expected. Please look into it and let me know your opinion.

    Test case A : Script :  as follows 





    String RandomText = CustomKeywords.'customKeywordPackage.RandomTextCreator.randomTextCreator'('ContentPlaceHolder1_txtAuditName',
    GlobalVariable.PrefixText) --- > ( This is To generate the random text and put the value in the Text field )








    return RandomText;       ------ > Returning the text as Below ( Test case  B First step ) 


    Note : Here I am storing the above return value in "Audit Name "

    Test Case B : Script as follows : 

    String AuditName = WebUI.callTestCase(findTestCase('Audit Scheduling - 003 - Schedule new audit'), ['AuditName' : ''], FailureHandling.STOP_ON_FAILURE)







    WebUI.setText(findTestObject('Audit Mapping/Page_Compliance Portal (2)/textarea_ctl00ContentPlaceHold'), 'AuditName') ------ > But there instead of the "Audit name ( stored ) text " .... the text "Audit name " itself passed to the Text box  :(


    So could you please help me.
  • Hi there

    The correct script should be:

    WebUI.setText(findTestObject(‘Audit Mapping/Page_Compliance Portal (2)/textarea_ctl00ContentPlaceHold’), AuditName)

    'AuditName' will be passed as itself because it's a string, not the variable. You should remove '  '

  • Hi  Vinh Nguyen,


    Thank you so much. Its worked finally :)


    Sridhar S

  • Hi Vinh Nguyen,

    I have a doubt over here... can we declare the above " Audit Name  ( Test case A returning String value ) " Variable as a global one.. so that i can use it wherever i want.

    Could you please assist me.


    Sridhar S

  • Yes you can. You don't need to 'return' it, just assign it with the global variable you want.

  • Hi Vinh Nguyen,

    Thanks for your help.

    This is how I have declared the global variable :

      GlobalVariable.NameOfGlobalVariable = RandomText
     --- > The above variable " NameOfGlobalVariable " --- in the global variable section as follows

    Name : NameOfGlobalVariable

    initValueType : String

    initValue = " "  ------- > ( Because  I am passing the value " RandomText "  from the script to the variable "NameOfGlobalVariable"  )


    are the above steps / assignments correct ??

    awaiting your response. Many thanks in advance.


    Sridhar S







  • Hi there,

    That's correct. Please give it a try.

  • Can we return multiple variables from one test case
  • how about trying getText and then setText to pass the extracted text from getText
  • Hi , can u share your solution, how u set a tc1 data as global and reused in TC2 . ? 
    I followed ur steps but my test pass without doing the action i want 
Sign In or Register to comment.