Tuesday, August 21, 2012

QTP SendKeys


In QTP below are the three ways we can send keyboard keys:

1)Using Type method
2)Using Sendkeys method
3)Using DeviceReplay object

*********************************************************************************
 Send the keys using Type method:
*********************************************************************************
Window(“Notepad”).Activate

Window(“Notepad”).WinEditor(“Edit”).Type "MicTAB"

*********************************************************************************
Send the keys using Sendkeys method:
*********************************************************************************
Set WshShell= CreateObject("WScript.Shell")

WshShell.Run "notepad"

'To write the letters
WshShell.SendKeys "RealworldQTP"

'to press Tab in the keyboard
WshShell.SendKeys "{TAB}"  

'To press Enter in the keyboard
 WshShell.SendKeys "{ENTER}"

 'To send the combination keys
WshShell.SendKeys “^c”   'here '^' represents Ctrl key  in the keyboard  

*******************************************************************************
 Send the keys using DeviceReplay object:
*********************************************************************************
Set obj = CreateObject(“Mercury.DeviceReplay”)
Window(“Notepad”).Activate
obj.PressKey 63

Note :Here 63 represents F5(ASCII value of F5 key is 63)

Wednesday, August 8, 2012

How to download QTP 11.0 trail version?


QTP 11.0 trail version download


1)Goto Below HP site:

          http://www8.hp.com/us/en/software-solutions/software.html?compURI=1172122#tab=TAB3

2) Click on Trail software under resources tab and click on below link

          HP Unified Functional Testing (with QTP) English Evaluation (GUI and API testing)

3 )Once click on above link site will ask for the personal details, enter all required data and click on next

4) Next page it will ask for Terms of Use, click on I agree button

5) Click on download button with name “HP QTP 11.00 Eval Package Eng SW E-Media”

Monday, August 6, 2012

ChildObjects in QTP

********************************************************************************
What is Chiledobjects in QTP:
********************************************************************************
      To count the number of same class object present in the window or page

********************************************************************************
Example:
********************************************************************************

Set obj=Description.Create
obj("micclass").value="WinButton"
Set objcol=Window("Flight Reservation").ChildObjects(obj)
msgbox objcol.count
********************************************************************************
'To get the property value of all objects:
********************************************************************************
For i=0 to objcol.count-1
msgbox objcol(i).getroproperty("name")
Next
********************************************************************************



Friday, August 3, 2012

Parameterization


*******************************************************************************
Parameter:

******************************************************************************* 
parameter is a special kind of variable, used in a function to refer to one of the pieces of data provided as input to the function.

 *******************************************************************************
Parameterization:

 *******************************************************************************
Parameterization is the process of replacing variable with a value.
 *******************************************************************************
Advantages of Parameterization:
*******************************************************************************
  • Parameterization allows us to pick different value at run time.
  • Reduces time and effort
  • it greatly increases the power and flexibility of our test
  • parameterization allows to perform data driven testing
 *******************************************************************************
 Without Parameterization:
*******************************************************************************
WinEdit(“Login”).Set “hi”
WinEdit(“Login”).Set “hello”
WinEdit(“Login”).Set “QTP”
 *******************************************************************************
 With Parameterization:

 *******************************************************************************
WinEdit(“Login”).Set DataTable(”Name”, dtglobalsheet)

*******************************************************************************
We Can do Parameterization in three ways:
*******************************************************************************
  • Using Data Table
  • Using Environment variables
  • Using Random number

Recording Modes

There are three types of recordings in QTP:


1) Normal Recording:

2) Analog Recording:

3). Low-Level Recording:

******************************************************************************
 Normal Recording:
******************************************************************************
           This is the default mode in QTP. It recognizes the objects in the application regardless of their location on screen.
For recording just click on Record button in QTP and start recording.

******************************************************************************
Analog Recording:
******************************************************************************
           In this recording QTP records and tracks every movement of the mouse as you drag the mouse around a screen or window.

******************************************************************************
Low-Level Recording:
******************************************************************************
            In this recording, QTP records the object in terms of its X and Y coordinators on the screen.

******************************************************************************

Thursday, August 2, 2012

Why GetROproperty,GetTOProperties and SetTOProperty

*************************************************************************
GetRoProperty:
*************************************************************************
    To get  the Runtime object propertie values

Example:

'In flght reservation application while inserting order,Order Number will get generated at runtime
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("New").Click
Window("Flight Reservation").WinObject("Date of Flight:").Type "121212"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Frankfurt"
Window("Flight Reservation").WinComboBox("Fly To:").Select "Los Angeles"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "QTP User"
Window("Flight Reservation").WinButton("Insert Order").Click
Wait 4
vOrderNumber = Window("Flight Reservation").WinEdit("Order No:").GetRoProperty("value")
 *************************************************************************
GetTOProperties :
*************************************************************************

                   We can get the property values of test objects,i.e For QTP which properties are helpful to identify the object 

Example:

  
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("New").Click
Window("Flight Reservation").WinObject("Date of Flight:").Type "121212"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Frankfurt"
Window("Flight Reservation").WinComboBox("Fly To:").Select "Los Angeles"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "QTP User"

msgbox Window("Flight Reservation").WinEdit("Name:").GetTOProperties ("name")
*************************************************************************

SetTOProperty:
*************************************************************************

             We can Modify the object property values at run time

Example:

r.Activate

Window("Flight Reservation").WinButton("New").Click
Window("Flight Reservation").WinObject("Date of Flight:").Type "121212"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Frankfurt"
Window("Flight Reservation").WinComboBox("Fly From:").SetTOProperty “attached text”, “Fly To:”
Window("Flight Reservation").WinComboBox("Fly From:").Select "Los Angeles"


Note:Here we don't need to add FlyTo object to OR











Reporter Object in QTP


*********************************************************************************
 ReporterObject:
*********************************************************************************

Using Repoter object we can send the customize results QTP result window

Below are the methods to work with Repoter object

• ReportEvent Method

• Filter Property

• ReportPath Property

• RunStatus Property

*********************************************************************************
ReportEvent Method:
*********************************************************************************

ReportEvent Method is used to send the user events to result  window

Syntax:
Reporter.ReportEvent EventStatus, ReportStepName, Details     For Reporterevent we need Pass the  three argumrnts
 1)EventStatus (Micpass,MicFail,micDone,micWarning)
 2)ReportStepName : Executing StepName
3)Details  := Description  about the  ReportStepName   ********************************************************************************
 Filter Property:

*********************************************************************************       
 By using Filter property we can filter the Eventstatus of the result window

  Example: Reporter.Filter = mode  

Modes:
 micPass
 micFail
micWarning
micDone    

If  mode is micPass it will filter the all passed steps 

 *********************************************************************************
ReportPath Property:
*********************************************************************************

Msgbox Reporter.ReportPath
It will give the path of result stored location
  *********************************************************************************
RunStatus Property:
*********************************************************************************  
Msgbox  Reporter.RunStatus
 It returns the status of current test during the test run.