Tuesday, May 20, 2008

QTP Script 6 - How to pass output parameter's value of one test to input parameter of another test.

' Open a new test and go to File->Settings, Parameters tab.
' Define an input parameter "inpar" as string with a default value of "Dvalue".
' Define one output parameter "outpar" as string.
' write the below lines of code in the Expert View of the test and save it as Test-p1 under C:\Program Files\Mercury Interactive\QuickTest Professional\Tests.

Testargs("outpar")=Testargs("inpar")

msgbox TestArgs("outpar")

' Open a new test and go to File->Settings, Parameters tab.
' Define an input parameter "inpar2" as string with a default value of "Dvalue2".
' write the below line of code in the Expert View of the test and save it as Test-p2
' under C:\Program Files\Mercury Interactive\QuickTest Professional\Tests.

msgbox testargs("inpar2")

' This below code is opening a test called Test-p1, setting its first input parameter to "Hello World" and running the test. Test-p1 is just assigning the input parameter to the output parameter when it is run and that output parameter is displayed in the messagebox. After that the value of the ouput parameter of the Test-p1 is being assigned to "val" so that it can be passed as input parameter to Test-p2. Test-p2 is just displaying the value of inpar2 which it got from Test-p1.