Wednesday, December 29, 2010

QTP- Passing multiple values between two actions by suing Action Parameters

Option Explicit
Dim a,b,sum1,diff1,prod1
a=10
b=20
RunAction "Action2", oneIteration,a,b,sum1,diff1,prod1
Msgbox "Sum:   "&sum1
Msgbox "Diff:   "&diff1
Msgbox "Prod:   "&prod1
--------------------------------------------------------------------
'Code for creating Input,output parameters
Option Explicit
Dim n1,n2,sum,diff,prod,s,d,p
n1=Parameter("Num1")
n2=Parameter("Num2")
sum=n1+n2
diff=n2-n1
prod=n1*n2
parameter("s")=sum
parameter("d")=diff
parameter("p")=prod
------------------------------------------------------------------
Edit-->Action-->ActionProperties-->Input,Output Parameters
'*********************************************************************
'Code for function procedures
Option Explicit
Dim a,b,sum,prod,val
a=10
b=20
Public Function Add1(ByRef a,ByRef b)
a=a+10
Msgbox "a value inside function:  "&a
b=b+10
Msgbox "b value inside function:  "&b
sum=a+b
Add1=sum
End Function
val=Add1(a,b)
'Call Add1(a,b)
'Add1 a,b
Msgbox "Sum:   "&val
Msgbox "a Value Out side Function:   "&a
Msgbox "b Value Out side Function:   "&b
'*********************************************************************
'Code for Built-In Environment Variables for reading system info
Msgbox Environment.Value("LocalHostName")
Msgbox Environment.Value("OS")
Msgbox Environment.Value("OSVersion")
Msgbox Environment.Value("ProductName")
Msgbox Environment.Value("ProductVer")
Msgbox Environment.Value("ProductDir")
Msgbox Environment.Value("TestDir")
Msgbox Environment.Value("ActionIteration")
Msgbox Environment.Value("TestIteration")
Msgbox Environment.Value("ResultDir")
'********************************************************************
'Code for reading external environment variables
Option Explicit
Dim path1
path1=Environment.ExternalFileName
Msgbox IsEmpty(path1)
If (path1="") Then
 Environment.LoadFromFile "C:\Documents and Settings\Administrator\Desktop\FastTrack\envfile.xml"
 Msgbox "UserID:     "&Environment.Value("UserID")
 Msgbox "Password:     "&Environment.Value("Password")
 Msgbox "Job:     "&Environment("Job")
 Msgbox "Age:     "&Environment("Age")
 Msgbox "Location:     "&Environment("Location")
 Else
 Msgbox "File Already in use:   "&path1
End If

1 comment: