Monday, November 10, 2008

QTP COURSE CONTENT

Q T P 9 .2

 Introduction to Automated Testing

v      Need of automation Testing

v      Difference between manual and automation Testing

v      Requirements to move from WinRunner to QTP

v      Introduction to QTP and Discussion on various versions of QTP

v      Understanding the complete test process of QTP

v      Discussion on the Difference between process and QTP process

v      Discussion on various components of the QTP window

v      Implementing GUI and Bit map Regression Test

v      Understanding Add-in manager

v      Working with Record and Run settings Tool options

v      Working with active screen

v      Working with debug viewer

v      Creating Test Scenarios /Components

v      Creating the basic script

v      Understanding the Objects Repository

v      Working with shared and per action object Repository

v      Working with the object spy option

v      Working with the check points for both windows and web applications

v      Working with the run time properties of various GUI objects

v      Understanding the Environment Variables

Actions

v      Introduction

v      Creating New Actions

v      Splitting Actions

v      Renaming Actions

v      Types of Actions

v      Normal Actions

 v      Reusable Actions

v      External Actions

v      Functions

v      Need of Functions

v      Creating User Defined Functions

v      Working with User Defined Functions

Libraries

v       Introduction    

v      Creating Library files

v      Associating Library file

 Step Generators

 Additional concepts

v      File System Object

v      Environment variables

v      Database Connections

v      MS Access

v      SQL Server

v      Oracle

v      Creating Log Files

 Virtual object Configuration

v      Recovery Scenario Manager

v      Introduction

v      Types of Trigger events

v      Creating the Recovery files

v      Associating the Recovery files

 Descriptive Programming

v      Introduction

v      Creating Descriptive Scripts Advantages

v      Regular Expressions

v      Introduction

v      Advantages of Regular Expressions

Reporting Methods
Working with the option result in test log


Creating a separate test Log File
Writing the results  testing to the log File
Reading the data from the text Files
XML Operations
ADVANCED OPTIONS
VB Scripting Language Options

Utility Objects

Coding standards for QTP

Frame work for the QTP Automation
Sessions on writing the script for a Window /Web based applications

Framework Implementation

v      Linear

v      Modular

v      Keyword Driven

v      Hybrid

 Quality Center and Connections to Quality Center

Posted by siri at 01:17:59 | Permalink | Comments (1) »

QTP SAMPLE VB SCRIPTS

Login Window:-

 

****To enter Data in U.N and Password fields…

Browser(“Yahoo”).Page(“Yahoo”).Webedit(“UserID”).Set”Aruna”
Browser(“Yahoo”).Page(“Yahoo”).Webedit(“Password”).Set”Aruna”

****Click on Login button***

Browser(“Yahoo”).Page(“Yahoo”).Webbutton(“Login”).Click

 

***Clicking on Link****

Browser(“Yahoo”).Page(“Yahoo”).Link(“Inbox”).Click

 

***Getting value from list box***

Browser(“Yahoo”).Page(“Yahoo”).Weblist(“List”).GetRoProperty(“text”) ….here text is the property name..

 
 
 
' 1.  To Count and display Object Properties and Values
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim Obj1,ObPrp
Set Obj1=Window ("Flight Reservation")
Set ObPrp=Obj1.GetToProperties
For i=0 To ObPrp.Count -1
 
        msgbox i+1 & " - " & ObPrp(i).Name & " ....... “& ObPrp(i).Value
Next
 
'2 . Login Verification with constant input values
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvokeApplication "C:\Program Files\Mercury Interactive\QuickTest 
Professional\samples\flight\app\flight4a.exe"
Dialog("Login").WinEdit("Agent Name:").Set "Pulse"
Dialog("Login").WinEdit("Password:").Set "Mury"
Dialog("Login").WinButton("OK").Click
If Dialog("Login").Dialog("Flight Reservations").Exist Then
Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
Dialog("Login").WinButton("Cancel").Click
Reporter.ReportEvent 1,"Login Verify","Invalid Values...Test Failed"
Else
Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"
Reporter.ReportEvent 0,"Login Verify","Valid Inputs...Test Passed"
End If
 
' 3. Login Verification with Runtime Input Values
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim Flights,Agt,Pwd
Flights="C:\Program Files\Mercury Interactive\QuickTest 
Professional\samples\flight\app\flight4a.exe"
For i=1 To 4
Agt=InputBox("Enter Agent Name Plzzz")
Pwd=InputBox("Enter PAssword ..Plzzz")
InvokeApplication Flights
Dialog("Login").WinEdit("Agent Name:").Set sreedhar
Dialog("Login").WinEdit("Password:").Set Pwd
Dialog("Login").WinButton("OK").Click
 
If Dialog("Login").Dialog("Flight Reservations").Exist Then
 wait(3)
  Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
wait(3)
 Dialog("Login").WinButton("Cancel").Click
Reporter.ReportEvent 1,"Login","Test Failed"
Else
Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"
Reporter.ReportEvent 0,"Login","Test Passed"
End If
Next
 
 
' 4. Login with Parameterization ... Data Table (Global Sheet) Should 
contain Values
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest 
Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury 
Interactive\QuickTest Professional\samples\flight\app","open"
'InvokeApplication "C:\Program Files\Mercury Interactive\QuickTest 
Professional\samples\flight\app\flight4a.exe"
Dialog("Login").WinEdit("Agent Name:").Set DataTable("Agent_Name", 
dtGlobalSheet)
Dialog("Login").WinEdit("Password:").Set DataTable("Pword", 
dtGlobalSheet)
Dialog("Login").WinButton("OK").Click
If Dialog("Login").Dialog("Flight Reservations").Exist Then
Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
Dialog("Login").WinButton("Cancel").Click
Reporter.ReportEvent 1,"Login Verify","Invalid Values...Test Failed"
DataTable.Value("Act_Res")="Fail"
Else
Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"
Reporter.ReportEvent 0,"Login Verify","Valid Inputs...Test Passed"
DataTable.Value("Act_Res")="Pass"
End If
 
        er=DataTable("Exp_Res",dtGlobalSheet)
        ar=DataTable("Act_Res",dtGlobalSheet)
 
        If StrComp(er,ar)=0 Then
               DataTable.Value("Remarks")="OK"
        Else
               DataTable.Value("Remarks")="Defect"
End If
        DataTable.Export("E:\QTP730\LoginResults.xls")
 
 
 
 
 
'5.   Compare Total Tickets and Amount for First 5 Orders
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tot_ts=0
Tot_amt=0
For Ord=1 To 5
 
Window("Flight Reservation").WinMenu("Menu").Select "File;Open 
Order..."
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order 
No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit_2").Set 
Ord
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Tkts=Window("Flight 
Reservation").WinEdit("Tickets:").GetROProperty("text")
Tot_ts = Tot_ts + Cint(Tkts)
Amt=Window("Flight 
Reservation").WinEdit("Total:").GetROProperty("text")
Tot_amt = Tot_amt + Cint(Amt)
Next
 
msgbox "Total Tickets are....." & Tot_ts
msgbox "Total Amount is....." & Tot_amt
 
' 6. To compare Customer Name and No.of tickets (Get and compare 
Paroperty Values)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Exp_Cna="Suresh"
Exp_tkts=5
Window("Flight Reservation").WinMenu("Menu").Select "File;Open 
Order..."
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order 
No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit_2").Set 
"15"
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Act_Cna=Window("Flight 
Reservation").WinEdit("Name:").GetROProperty("text")
Act_Tkts=WinDow("Flight 
Reservation").WinEdit("Tickets:").GetROProperty("text")
 
If StrComp(Exp_Cna,Act_Cna)=0 Then
        Reporter.ReportEvent 0,"Cust_Name","Customer is OK   " & Exp_Cna & " 
...." & Act_Cna
Else
        Reporter.ReportEvent 1,"Cust_Name","Customer is Not OK   " & Exp_Cna & 
" ...." & Act_Cna
End If
If Exp_tkts=Cint(Act_tkts) Then
        Reporter.ReportEvent 0,"No_Tickets","Tickets are OK   " & Exp_tkts & " 
...." & Act_tkts
Else
        Reporter.ReportEvent 1,"No_Tickets","Tickets are Not OK   " & Exp_tkts 
& " ...." & Act_tkts
End If
 
 
 
'7.  Example of CrateObject....to execute an application
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim MyObj
Set MyObj = CreateObject("Wscript.Shell")
MyObj.Run "Excel.Exe"
wait(5)
MyObj.Run "Notepad.Exe"
 
 
' 8. Object Verification
'~~~~~~~~~~~~~~~~~
Dim Flights,Calc
Calc="c:\windows\system32\calc.exe"
Flights="C:\Program Files\Mercury Interactive\QuickTest 
Professional\samples\flight\app\flight4a.exe"
InvokeApplication Calc
'InvokeApplication Flights
wait(3)
If Dialog("Login").Exist Then
        msgbox "Login Existed"
Else
        msgbox "Login Not Existed"
End If
 
 
' 9.  to get a single Property Value
'~~~~~~~~~~~~~~~~~~~~~~~~~
Dim Dlog,Agt
Set Dlog = Dialog("Login")
Set Agt = Dlog.WinEdit("Agent Name:")
agent=Agt.GetROProperty("text")
msgbox "Agent Name is ......" & agent
 
 
'10.  To get all property values of an object
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim Dlog,Agt,Props
Set Dlog = Dialog("Login")
Set Agt = Dlog.WinEdit("Agent Name:")
 
Set Props = Agt.GetToProperties
msgbox "Total Properties are...." & Props.Count
 
        For i=0 To Props.Count -1
msgbox i+1 & ".  Property...." & Props(i).Name & " ....." & 
Props(i).Value
        Next
 
 
' 11. Text Comparision
'~~~~~~~~~~~~~~~~~
agt=InputBox("Agent Name Plzzz....")
Expt_Agt="Pulse"
InvokeApplication "C:\Program Files\Mercury Interactive\QuickTest 
Professional\samples\flight\app\flight4a.exe"
Dialog("Login").WinEdit("Agent Name:").Set agt
Act_Agt=Dialog("Login").WinEdit("Agent Name:").GetROProperty("text")
If StrComp(Expt_Agt,Act_Agt)=0 Then
        Dialog("Login").WinEdit("Password:").Set "Mercury"
        Dialog("Login").WinButton("OK").Click
Else
        msgbox "Expt..." & Expt_Agt & " ..Actual ...." &Act_Agt
        Dialog("Login").WinButton("Cancel").Click
End If
 
' 12. Working with Transactions
'~~~~~~~~~~~~~~~~~~~~~~~~
Services.StartTransaction "test1"
 
Services.StartTransaction "Log1"
Window("Program Manager").WinListView("SysListView32").Activate 
"QTPflights"
Dialog("Login").WinEdit("Agent Name:").Set "asasasa"
Dialog("Login").WinEdit("Password:").SetSecure 
"4484160870f801d29b69e178723a172e57e00b6a"
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Move 87,74
Services.EndTransaction "Log1"
Services.StartTransaction "op1"
 
Services.StartTransaction "Ins1"
Window("Flight Reservation").WinMenu("Menu").Select "File;New Order"
Window("Flight Reservation").WinObject("Date of Flight:").Type "060606"
Window("Flight Reservation").WinComboBox("Fly From:").Select "London"
Window("Flight Reservation").WinComboBox("Fly To:").Select "Frankfurt"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights 
Table").WinList("From").Activate "12492   LON   10:24 AM   FRA   11:09 AM   AA     $104.00"
Window("Flight Reservation").WinEdit("Name:").Set "asdfgh"
Window("Flight Reservation").WinButton("Insert Order").Click
Window("Flight Reservation").WinMenu("Menu").Select "File;New Order"
Services.EndTransaction "Ins1"
Services.StartTransaction "Fax1"
Window("Flight Reservation").WinMenu("Menu").Select "File;Open 
Order..."
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
Window("Flight Reservation").WinMenu("Menu").Select "File;Fax Order..."
Window("Flight Reservation").Dialog("Fax Order No. 1").WinObject("Fax 
Number:").Type "12122121212"
Window("Flight Reservation").Dialog("Fax Order No. 
1").WinButton("Send").Click
Window("Flight Reservation").WinMenu("Menu").Select "File;New Order"
Services.EndTransaction "Fax1"
 
Services.EndTransaction "op1"
Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"
Services.EndTransaction "test1"
 
 
****** Run the Script and open Test Result and from Test Summary select 
End Transaction Statement
will diasplays the Operation Execution time.
 
 
 
Working with Actions:
 
Working with Actions:
        1. Recording into Multiple Actions
        2. Slipt Action 
        3. Copy of Action
        4. Call to Action
        5. Change Action Properties
        6. Types of Actions
               a. Internal Actions
               b. External Actions
               c. Nested Actions
               d. Reusable Actions
               e. Non-Reusable Actions
        7. Parameterization with Action
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'To Create an Excel Sheet
Dim ExcelSheet
Set ExcelSheet = CreateObject("Excel.Sheet")
ExcelSheet.Application.Visible = True
ExcelSheet.ActiveSheet.Cells(1,1).Value = "Surya"
ExcelSheet.ActiveSheet.Cells(1,2).Value = "Testing"
ExcelSheet.ActiveSheet.Cells(1,3).Value = "KPHB"
ExcelSheet.ActiveSheet.Cells(1,4).Value = "No DUE"
 
ExcelSheet.SaveAs "d:\class6qtp\mysheet.XLS"
ExcelSheet.Application.Quit
Set ExcelSheet = Nothing
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
'Open and Execute QTP Test with VBS
Dim Ttool,Qtest
Qtest= "d:\class6qtp\LoginTest1"
Set Ttool=CreateObject("QuickTest.Application")
Ttool.Launch
Ttool.Visible=True
Ttool.open Qtest
Ttool.Test.Run
Ttool.Test.close
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Create environment variables:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<Environment>
        <Variable>
               <Name>agent</Name>
               <Value>Pulse</Value>
        </Variable>
        <Variable>
               <Name>flights</Name>
               <Value>"C:\Program Files\Mercury Interactive\QuickTest 
Professional\samples\flight\app\flight4a.exe"</Value>
        </Variable>
        <Variable>
               <Name>password</Name>
               <Value>mercury</Value>
        </Variable>
</Environment>
 

Plain Text Attachment [ Scan and Save to Computer | Save to Yahoo! Briefcase ]

' 1.  To Count and display Object Properties and Values
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim Obj1,ObPrp
Set Obj1=Window("Flight Reservation")
Set ObPrp=Obj1.GetToProperties
For i=0 To ObPrp.Count -1
 
        msgbox i+1 & " - " & ObPrp(i).Name & " ....... " & ObPrp(i).Value
Next
 
'2 . Login Verification with constant input values
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvokeApplication "C:\Program Files\Mercury Interactive\QuickTest 
Professional\samples\flight\app\flight4a.exe"
Dialog("Login").WinEdit("Agent Name:").Set "Pulse"
Dialog("Login").WinEdit("Password:").Set "Mury"
Dialog("Login").WinButton("OK").Click
If Dialog("Login").Dialog("Flight Reservations").Exist Then
Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
Dialog("Login").WinButton("Cancel").Click
Reporter.ReportEvent 1,"Login Verify","Invalid Values...Test Failed"
Else
Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"
Reporter.ReportEvent 0,"Login Verify","Valid Inputs...Test Passed"
End If
 
' 3. Login Verification with Runtime Input Values
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim Flights,Agt,Pwd
Flights="C:\Program Files\Mercury Interactive\QuickTest 
Professional\samples\flight\app\flight4a.exe"
For i=1 To 4
Agt=InputBox("Enter Agent Name Plzzz")
Pwd=InputBox("Enter PAssword ..Plzzz")
InvokeApplication Flights
Dialog("Login").WinEdit("Agent Name:").Set Agt
Dialog("Login").WinEdit("Password:").Set Pwd
Dialog("Login").WinButton("OK").Click
 
If Dialog("Login").Dialog("Flight Reservations").Exist Then
 wait(3)
  Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
wait(3)
 Dialog("Login").WinButton("Cancel").Click
Reporter.ReportEvent 1,"Login","Test Failed"
Else
Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"
Reporter.ReportEvent 0,"Login","Test Passed"
End If
Next
 
 
' 4. Login with Parameterization ... Data Table (Global Sheet) Should 
contain Values
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest 
Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury 
Interactive\QuickTest Professional\samples\flight\app","open"
'InvokeApplication "C:\Program Files\Mercury Interactive\QuickTest 
Professional\samples\flight\app\flight4a.exe"
Dialog("Login").WinEdit("Agent Name:").Set DataTable("Agent_Name", 
dtGlobalSheet)
Dialog("Login").WinEdit("Password:").Set DataTable("Pword", 
dtGlobalSheet)
Dialog("Login").WinButton("OK").Click
If Dialog("Login").Dialog("Flight Reservations").Exist Then
Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
Dialog("Login").WinButton("Cancel").Click
Reporter.ReportEvent 1,"Login Verify","Invalid Values...Test Failed"
DataTable.Value("Act_Res")="Fail"
Else
Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"
Reporter.ReportEvent 0,"Login Verify","Valid Inputs...Test Passed"
DataTable.Value("Act_Res")="Pass"
End If
 
        er=DataTable("Exp_Res",dtGlobalSheet)
        ar=DataTable("Act_Res",dtGlobalSheet)
 
        If StrComp(er,ar)=0 Then
               DataTable.Value("Remarks")="OK"
        Else
               DataTable.Value("Remarks")="Defect"
End If
        DataTable.Export("E:\QTP730\LoginResults.xls")
 
 
 
 
 
'5.   Compare Total Tickets and Amount for First 5 Orders
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tot_ts=0
Tot_amt=0
For Ord=1 To 5
 
Window("Flight Reservation").WinMenu("Menu").Select "File;Open 
Order..."
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order 
No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit_2").Set 
Ord
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Tkts=Window("Flight 
Reservation").WinEdit("Tickets:").GetROProperty("text")
Tot_ts = Tot_ts + Cint(Tkts)
Amt=Window("Flight 
Reservation").WinEdit("Total:").GetROProperty("text")
Tot_amt = Tot_amt + Cint(Amt)
Next
 
msgbox "Total Tickets are....." & Tot_ts
msgbox "Total Amount is....." & Tot_amt
 
' 6. To compare Customer Name and No.of tickets (Get and compare 
Paroperty Values)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Exp_Cna="Suresh"
Exp_tkts=5
Window("Flight Reservation").WinMenu("Menu").Select "File;Open 
Order..."
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order 
No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit_2").Set 
"15"
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Act_Cna=Window("Flight 
Reservation").WinEdit("Name:").GetROProperty("text")
Act_Tkts=WinDow("Flight 
Reservation").WinEdit("Tickets:").GetROProperty("text")
 
If StrComp(Exp_Cna,Act_Cna)=0 Then
        Reporter.ReportEvent 0,"Cust_Name","Customer is OK   " & Exp_Cna & " 
...." & Act_Cna
Else
        Reporter.ReportEvent 1,"Cust_Name","Customer is Not OK   " & Exp_Cna & 
" ...." & Act_Cna
End If
If Exp_tkts=Cint(Act_tkts) Then
        Reporter.ReportEvent 0,"No_Tickets","Tickets are OK   " & Exp_tkts & " 
...." & Act_tkts
Else
        Reporter.ReportEvent 1,"No_Tickets","Tickets are Not OK   " & Exp_tkts 
& " ...." & Act_tkts
End If
 
 
 
'7.  Example of CrateObject....to execute an application
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim MyObj
Set MyObj = CreateObject("Wscript.Shell")
MyObj.Run "Excel.Exe"
wait(5)
MyObj.Run "Notepad.Exe"
 
 
' 8. Object Verification
'~~~~~~~~~~~~~~~~~
Dim Flights,Calc
Calc="c:\windows\system32\calc.exe"
Flights="C:\Program Files\Mercury Interactive\QuickTest 
Professional\samples\flight\app\flight4a.exe"
InvokeApplication Calc
'InvokeApplication Flights
wait(3)
If Dialog("Login").Exist Then
        msgbox "Login Existed"
Else
        msgbox "Login Not Existed"
End If
 
 
' 9.  to get a single Property Value
'~~~~~~~~~~~~~~~~~~~~~~~~~
Dim Dlog,Agt
Set Dlog = Dialog("Login")
Set Agt = Dlog.WinEdit("Agent Name:")
agent=Agt.GetROProperty("text")
msgbox "Agent Name is ......" & agent
 
 
'10.  To get all property values of an object
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim Dlog,Agt,Props
Set Dlog = Dialog("Login")
Set Agt = Dlog.WinEdit("Agent Name:")
 
Set Props = Agt.GetToProperties
msgbox "Total Properties are...." & Props.Count
 
        For i=0 To Props.Count -1
msgbox i+1 & ".  Property...." & Props(i).Name & " ....." & 
Props(i).Value
        Next
 
 
' 11. Text Comparision
'~~~~~~~~~~~~~~~~~
agt=InputBox("Agent Name Plzzz....")
Expt_Agt="Pulse"
InvokeApplication "C:\Program Files\Mercury Interactive\QuickTest 
Professional\samples\flight\app\flight4a.exe"
Dialog("Login").WinEdit("Agent Name:").Set agt
Act_Agt=Dialog("Login").WinEdit("Agent Name:").GetROProperty("text")
If StrComp(Expt_Agt,Act_Agt)=0 Then
        Dialog("Login").WinEdit("Password:").Set "Mercury"
        Dialog("Login").WinButton("OK").Click
Else
        msgbox "Expt..." & Expt_Agt & " ..Actual ...." &Act_Agt
        Dialog("Login").WinButton("Cancel").Click
End If
 
' 12. Working with Transactions
'~~~~~~~~~~~~~~~~~~~~~~~~
Services.StartTransaction "test1"
 
Services.StartTransaction "Log1"
Window("Program Manager").WinListView("SysListView32").Activate 
"QTPflights"
Dialog("Login").WinEdit("Agent Name:").Set "asasasa"
Dialog("Login").WinEdit("Password:").SetSecure 
"4484160870f801d29b69e178723a172e57e00b6a"
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Move 87,74
Services.EndTransaction "Log1"
Services.StartTransaction "op1"
 
Services.StartTransaction "Ins1"
Window("Flight Reservation").WinMenu("Menu").Select "File;New Order"
Window("Flight Reservation").WinObject("Date of Flight:").Type "060606"
Window("Flight Reservation").WinComboBox("Fly From:").Select "London"
Window("Flight Reservation").WinComboBox("Fly To:").Select "Frankfurt"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights 
Table").WinList("From").Activate "12492   LON   10:24 AM   FRA   11:09 AM   AA     $104.00"
Window("Flight Reservation").WinEdit("Name:").Set "asdfgh"
Window("Flight Reservation").WinButton("Insert Order").Click
Window("Flight Reservation").WinMenu("Menu").Select "File;New Order"
Services.EndTransaction "Ins1"
Services.StartTransaction "Fax1"
Window("Flight Reservation").WinMenu("Menu").Select "File;Open 
Order..."
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
Window("Flight Reservation").WinMenu("Menu").Select "File;Fax Order..."
Window("Flight Reservation").Dialog("Fax Order No. 1").WinObject("Fax 
Number:").Type "12122121212"
Window("Flight Reservation").Dialog("Fax Order No. 
1").WinButton("Send").Click
Window("Flight Reservation").WinMenu("Menu").Select "File;New Order"
Services.EndTransaction "Fax1"
 
Services.EndTransaction "op1"
Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"
Services.EndTransaction "test1"
 
 
****** Run the Script and open Test Result and from Test Summary select 
End Transaction Statement
will diasplays the Operation Execution time.
 
 
 
Working with Actions:
 
Working with Actions:
        1. Recording into Multiple Actions
        2. Slipt Action 
        3. Copy of Action
        4. Call to Action
        5. Change Action Properties
        6. Types of Actions
               a. Internal Actions
               b. External Actions
               c. Nested Actions
               d. Reusable Actions
               e. Non-Reusable Actions
        7. Parameterization with Action
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'To Create an Excel Sheet
Dim ExcelSheet
Set ExcelSheet = CreateObject("Excel.Sheet")
ExcelSheet.Application.Visible = True
ExcelSheet.ActiveSheet.Cells(1,1).Value = "Surya"
ExcelSheet.ActiveSheet.Cells(1,2).Value = "Testing"
ExcelSheet.ActiveSheet.Cells(1,3).Value = "KPHB"
ExcelSheet.ActiveSheet.Cells(1,4).Value = "No DUE"
 
ExcelSheet.SaveAs "d:\class6qtp\mysheet.XLS"
ExcelSheet.Application.Quit
Set ExcelSheet = Nothing
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
'Open and Execute QTP Test with VBS
Dim Ttool,Qtest
Qtest= "d:\class6qtp\LoginTest1"
Set Ttool=CreateObject("QuickTest.Application")
Ttool.Launch
Ttool.Visible=True
Ttool.open Qtest
Ttool.Test.Run
Ttool.Test.close
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Create environment variables:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<Environment>
        <Variable>
               <Name>agent</Name>
               <Value>Pulse</Value>
        </Variable>
        <Variable>
               <Name>flights</Name>
               <Value>"C:\Program Files\Mercury Interactive\QuickTest 
Professional\samples\flight\app\flight4a.exe"</Value>
        </Variable>
        <Variable>
               <Name>password</Name>
               <Value>mercury</Value>
        </Variable>
</Environment>
 

 

Posted by siri at 01:06:58 | Permalink | Comments (1) »