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

 

 

 

 

Comments

  • 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.

    Thanks

    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.

    Thanks

    Sridhar S

     
  • Hi  Vinh Nguyen,

     

    Thank you so much. Its worked finally :)

    Regards

    Sridhar S

     
  • 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 

    WebUI.openBrowser('')

    WebUI.navigateToUrl('https://172.18.1.2/complianceportal/login.aspx')

    WebUI.acceptAlert()

     

    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 )

     

    :

    :

    :

    WebUI.delay(5)

    WebUI.acceptAlert()

    WebUI.delay(4)

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

    WebUI.closeBrowser()

    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.openBrowser('')

    :

    :

    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.
  • 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 :)

    Thanks

    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.
Sign In or Register to comment.