Micro Focus QTP (UFT) Forums
how to call reusable actions by passing parameters.? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: how to call reusable actions by passing parameters.? (/Thread-how-to-call-reusable-actions-by-passing-parameters)



how to call reusable actions by passing parameters.? - Arun091 - 08-16-2012

Hi All,

Below is the sample action code
###############################
======== Login Action ========
Code:
Dialog"Login").WinEdit"Agent Name:").Set "username"
Dialog"Login").WinEdit"Password:").SetSecure "password"
Dialog"Login").WinButton"OK").Click

======== Insert_order Action ========
Code:
Window"Flight Reservation").ActiveX"MaskEdBox").Type "parameter1"
Window"Flight Reservation").WinComboBox"Fly From:").Select "parameter2"
Window"Flight Reservation").WinComboBox"Fly To:").Select "parameter3"
Window"Flight Reservation").WinButton"FLIGHT").Click
Window"Flight Reservation").Dialog"Flights Table").WinButton"OK").Click
Window"Flight Reservation").WinEdit"Name:").Set "parameter4"
Window"Flight Reservation").WinButton"Insert Order").Click

======== Logout Action ========
Code:
Window"Flight Reservation").WinMenu"Menu").Select "File;Exit"
###############################

1) These are the reusable actions which I'm using
a. Login
b. Insert_order
c. Logout

2) I'm using MS excel for database.
a. login database for fields (username,password)
b. insertodrer database for fields (date, Fly From, Fly To, Flight, Name)


Question :
Now I have to create this program in a below mentioned flow
———————————————–
Code:
call "login" action                 //pass parameters here (i.e. username/password from xls)
        if login sucessful
            call "Insert_order" action    //pass parameters here (i.e. date, Fly From, Fly To, Flight, Name frm xls)
            call "Logout" action
        endif
        return the result of test in a separate xls files
———————————————–

Please help me in getting these resolved.
Or what is the best way to do this type of case?

Thanks
Arun