QTP


                 QTP Functions
Vb script Procedures / Functions
-------------------------------
User defined Functions
----------------------

Sub Procedures

Function Procedures
-------------------


Sub Procedure

Set of statements enclosed with sub and End Sub statements

To perform a task/tasks

Won't return any value

takes arguments but arguments are optional

Syntax:
--------

Sub procedure name (Arguments)

Statements
--------
--------
---------
End Sub

---------------------------------------------------
Function Procedure

Set of statements enclosed with Function and End Function statements

To perform a task/tasks

Can return a value

takes arguments but arguments are optional

Syntax:
--------
Function procedure name (Arguments)

Statements
--------
--------
---------
End Function
-------------------------------------------
Examples:
----------
'Sub Procedure for Login Operation with No Arguments
Sub Login()
        SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\HP\QuickTest Professional\samples\flight\app\","open"
        Dialog("Login").Activate
        Dialog("Login").WinEdit("Agent Name:").Set "asdf"
        Dialog("Login").WinEdit("Password:").SetSecure "4eb12a45b87525a4de255f3003d1dd1edab5e785"
        Dialog("Login").WinButton("OK").Click
        Window("Flight Reservation").Close
End Sub
-----------------------------------------------------
'Sub Procedure for Login Operation with Arguments
Sub Login(Agent, Password)
        SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\HP\QuickTest Professional\samples\flight\app\","open"
        Dialog("Login").Activate
        Dialog("Login").WinEdit("Agent Name:").Set Agent
        Dialog("Login").WinEdit("Password:").Set Password
        wait 2
        Dialog("Login").WinButton("OK").Click
        Window("Flight Reservation").Close
End Sub
------------------------------------------------
'Sub Procedure for Login Operation with Arguments
Sub Login(Agent, Password)
Loading Repositories directly from the Function
RepositoriesCollection.Add "C:\Documents and Settings\gcr\Desktop\Repository1.tsr"
        SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\HP\QuickTest Professional\samples\flight\app\","open"
        Dialog("Login").Activate
        Dialog("Login").WinEdit("Agent Name:").Set Agent
        Dialog("Login").WinEdit("Password:").Set Password
        wait 2
        Dialog("Login").WinButton("OK").Click
        Window("Flight Reservation").Close
End Sub
----------------------------------------------------
'Login Sub procedure for Data driven Testing
Sub Login(Agent, Password)
        SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\HP\QuickTest Professional\samples\flight\app\","open"
        Dialog("Login").Activate
        Dialog("Login").WinEdit("Agent Name:").Set Agent
        Dialog("Login").WinEdit("Password:").Set Password
        Wait 1
        Dialog("Login").WinButton("OK").Click
        Window("Flight Reservation").Close
End Sub
Call Login(DataTable("Agent",1),DataTable("Password",1))
-------------------------------------------------------
'Sub procedure with arguments, verification point and return Result
Sub Login(Agent, Password)
        SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
        Dialog("text:=Login").Activate
        Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set Agent
        Dialog("text:=Login").WinEdit("attached text:=Password:").Set Password
        Dialog("text:=Login").WinButton("text:=OK").Click

If  Window("text:=Flight Reservation").Exist(12) Then
                Window("text:=Flight Reservation").Close
                Res="Login Successful"
                Else
     Res="Login Failed"
         SystemUtil.CloseDescendentProcesses
End If
Msgbox Res
End Sub
---------------------------------------------
'Function procedure with arguments, verification point and return Result
Function Login(Agent, Password)
        SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
        Dialog("text:=Login").Activate
        Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set Agent
        Dialog("text:=Login").WinEdit("attached text:=Password:").Set Password
        Dialog("text:=Login").WinButton("text:=OK").Click

If  Window("text:=Flight Reservation").Exist(12) Then
                Window("text:=Flight Reservation").Close
                Login="Login Successful"
                Else
     Login="Login Failed"
         SystemUtil.CloseDescendentProcesses
End If
End Function
x=Login("abce","mercury")
Msgbox x
---------------------------------------------------
'Function Procedure for returning multiple values
Function Verify_UpdateOrder()
        Window("Flight Reservation").Activate
        Before_Open = Window("Flight Reservation").WinButton("Update Order").GetROProperty("enabled")
       
        If  Before_Open=False Then
                Verify1="Update Order Button Disabled"
                Else
          Verify1="Update Order Button Enabled"
        End If
        Window("Flight Reservation").WinButton("Button").Click
        Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
        Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "1"
        Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
        After_Open = Window("Flight Reservation").WinButton("Update Order").GetROProperty("enabled")
       
        If  After_Open=True Then
                Verify2="Update Order Button Enabled"
                Else
          Verify2="Update Order Button Disabled"
        End If
Verify_UpdateOrder=Array(Verify1, Verify2)
End Function

x=Verify_UpdateOrder()

Msgbox x(0)
Msgbox x(1)
----------------------------------------------------

'Write a function for Launching the Application
Function Launch_App()
   SystemUtil.Run "C:\Program Files\Internet Explorer\iexplore.exe","http://prep-uk.rs-online.com/web/home.html"
Page_URL = Browser("RS | Electronic components,").Page("RS | Electronic components,").GetROProperty("url")

If  Page_URL ="http://prep-uk.rs-online.com/web/home.html"  Then
Launch_App="Application launched successfully"
Else
Launch_App="Application Not launched"
End If
Msgbox Launch_App
End Function
Call Launch_App()
-----------------------------------------------------
'Write a function for Counting Objects from RS compenets web portal Home Page
Function Count_Objects()
   Dim oObject, Objects, TotObjects
SystemUtil.Run "C:\Program Files\Internet Explorer\iexplore.exe","http://prep-uk.rs-online.com/web/home.html"
Set oObject=Description.Create()
Set Objects=Browser("RS | Electronic components,").Page("RS | Electronic components,").ChildObjects(oObject)
TotObjects=Objects.Count
Msgbox TotObjects
End Function
Call Count_Objects()
----------------------------------------------------
'Write a function for Counting Links from RS components web portal Home Page
Function Count_Links()
   Dim oLink, Links, TotLinks
SystemUtil.Run "C:\Program Files\Internet Explorer\iexplore.exe","http://prep-uk.rs-online.com/web/home.html"
Set oLink=Description.Create()
oLink("micclass").Value="Link"
Set Links=Browser("RS | Electronic components,").Page("RS | Electronic components,").ChildObjects(oLink)
TotLinks=Links.Count
Msgbox TotLinks
End Function
Call Count_Links()




qtp 11 installation requirements

Minimum System Requirements and Supported Environments

To successfully install and run QuickTest Professional, your computer must meet the minimum system requirements shown below. However, performance may be improved by using systems with stronger/later setups than the minimum requirements.


Computer/Processor:  Pentium IV or higher microprocessor (minimum 1 Ghz)

Operating System:     Windows XP Service Pack 2

Memory:     Minimum of 1GB when no more than three add-ins are loaded simultaneously.

Additional memory is required when loading more add-ins and when using the Save movie to results option to capture movies during run sessions.

Color Settings:     High Color (16 bit).

Graphics Card:     Graphics card with 64 MB video memory
Free Hard Disk Space:   GB of free disk space for application files and folders.
You must also have an additional 120 MB of free disk space on the system disk (the disk on which the operating system is installed).

Browser: Microsoft Internet Explorer 6.0 Service Pack 1 or a later supported version.

0 comments:

Post a Comment