SlideShare a Scribd company logo
1 of 53
For QTP Scripts & Other Information visit: www.gcreddy.com



       QuickTest Professional




                                    QuickTest Professional 10.00

                                   Product ID: QTPRPID 10.00/0

                                             Version: 10.00.0.0

                                                      Build: 513



                          By www.gcreddy.com

                www.GCREDDY.COM                                1
For QTP Scripts & Other Information visit: www.gcreddy.com


                                Index

 I. Basic Features of QTP
II. Key Elements of QTP
III. QTP Testing Process
IV. Generating Tests
V. Enhancing Tests
VI. Debugging & Running Tests
VII. Actions
VIII. Functions
IX. Regular Expressions
X. Environment Variables
XI.




                       www.GCREDDY.COM                             2
For QTP Scripts & Other Information visit: www.gcreddy.com


                        I) Basic features of QTP

o QTP Launched in 2002 (Nov). By Mercury Interactive. Later taken over by HP, in
    2007.
o QTP is an Object Based Testing Tool.
o QTP is for functional and Regression Testing.
o   It follows Keyword driven approach.
o It supports Windows Operating Environment only.
o It supports GUI based (Graphical user interface) and Web based Applications
    Automation, does not support CUI (Command user interface) Applications.
o   It has multilingual support. (It supports English, Chinese, Japanese, Korean, etc
    languages with respect to license.)
o It has adapted Microsoft Visual Basic Scripting edition for programming and excel
    like spread sheet for Data driven testing.
o SQL (Structured query language) embedded or inserted with QTP, so we can use
    SQL statements directly from QTP.
o It can be integrated with other Tools like WinRunner and Quality Center.
o It can be used for user interface (UI) test case automation and some limited (Non
    UI) Test case automation like File system operations and Data base operations.
o   It was derived from Astra QuickTest (mother tool of QTP).
o It supports IE (Internet Explorer) only for recording tests, for execution it supports
    other browsers like Mozilla and AOL, opera Etc apart from IE.
o QTP is a Desktop Application (I-Tier/Stand alone).
o QTP has two types of License,
            1. Seat or Node locked License,
            2. Concurrent or float license.
    Seat license for one system and Concurrent License, we can use for any system but
    one user at any time. If we want multiple concurrent licenses we can purchase.
o QTP has UNI code support.




                         www.GCREDDY.COM                                                3
For QTP Scripts & Other Information visit: www.gcreddy.com




Version History of QTP

              •   Astra Quick test (Mother tool of QTP) 1.0 to 5.0
              •   Quick Test Professional

              •   5.6 – Nov 2002
              •   6.5 – 2003
              •   8.0 – 2004
              •   8.2, 8.3 –2005
              •   9.0,9.1-2006
              •   9.2- 2007 mercury interactive
              •   9.5 –2008 H.P

              •   10.00 –2009 January


Add-In Manager


QTP supports almost all industry leading technologies, but by default it does not support,
with respect to add in license it supports.

Default Add- ins of QTP are:


              •   Activex
              •   Visual basic
              •   Web.



Other available Add Ins are: .Dot NET, Java, People soft, Siebel, TE (Terminal Emulators),
SAP for GUI, Sap for Web, Oracle Apps, Web Services etc.

During QTP launching it shows Add in manger dialog box, Add in Manger lists out all
available Add Ins in the company.

User needs to select appropriate Add Ins for his application or AUT.

One can select more than one Add Ins also; if we select unnecessary Add Ins QTP
performance will be reduced.




                            www.GCREDDY.COM                                                  4
For QTP Scripts & Other Information visit: www.gcreddy.com




Launching QTP

We can launch QTP BY selecting desktop icon otherwise start > programs> QTP
Professional > QTP.


During launching it shows Add-In Manager.




                               Add-in manager window

Select appropriate Add Ins and click okay.

Quick Test Launches




                           www.GCREDDY.COM                                    5
For QTP Scripts & Other Information visit: www.gcreddy.com




     II) Key Elements of QTP Tool Window




                www.GCREDDY.COM                              6
For QTP Scripts & Other Information visit: www.gcreddy.com

                                     QTP Tool Window

1) Test Pane:
It is programming interface of QTP, used for creating, editing, viewing and deleting test
scripts.

Test: It is a set of statements or set of one or more actions. (It is a local concept)

Action: It is a set of Statements. (It is a local concept)

Statement: A minimal executable unit. Statements may have keywords. (Keyword such
as function, method, statement etc). It is a global concept.

Test pane has 2 views.

Expert view- Test in VB script format.




                            www.GCREDDY.COM                                                 7
For QTP Scripts & Other Information visit: www.gcreddy.com

                     QTP Test Pane-Expert View

Key word view- Test in Icon based GUI format.




                     QTP Test Pane-Keyword View

Note1: Here in test pane Test is same but views are different, if you perform any
modifications in one view those automatically reflects in another view.


Note 2: Technical users use expert view and business user use key word view.

Note 3: User can customize Test pane view options.

Navigation: Tools Menu> view options> we can use font size and colors etc.

2) Active Screen




                           www.GCREDDY.COM                                          8
For QTP Scripts & Other Information visit: www.gcreddy.com

It has an optional element of QTP, it takes snap shots of every statement that user
performed action or operation on AUT.

It can be used for understanding and editing the test easily.

Navigation: View menu>active screen (for launching and closing)

Configuring active screen: view>options>active screen tab>increase /Decrease capture
level, apply and okay.

Note 1: Generally novice testers use this feature but it occupies lot of memory space on
QTP.




                            www.GCREDDY.COM                                                9
For QTP Scripts & Other Information visit: www.gcreddy.com




                                        Active Screen
3) Data Table

It has an integrated spread sheet (Excel like), used for Data driven testing.
Navigation: View menu>Data table (for launching and closing)

Data driven Testing: Testing the same task(S) or same operation with multiple sets of test
data.
It can be used in two ways.




                            www.GCREDDY.COM                                            10
For QTP Scripts & Other Information visit: www.gcreddy.com

   1. Enter test data directly into Data Table and use.
   2. Importing data from external files (Flat files, excel sheets, etc) and Data bases (MS
      access, Sql Server, oracle, etc.)

   It has two types of sheets.

   1. Global Sheet- for entire test /used for all actions in the test.
   2. Action Sheets- for specific action only.

Data table available in 2 ways:

   1. Design time data table. (Attached with every test)
   2. Run time data table. (Available in result window)

Run time is a carbon copy of design time data table.

QTP has Data table methods for performing operations on data table.




                            www.GCREDDY.COM                                             11
For QTP Scripts & Other Information visit: www.gcreddy.com




                       QTP Tool window- Data Table

4) Debug Viewer


It is used for locating and rectifying or fixing errors.

It can be used for debugging the tests by step-by-step execution.

We use step into, step over and step out commands for debugging. (debug commands)




                             www.GCREDDY.COM                                        12
For QTP Scripts & Other Information visit: www.gcreddy.com

Through Debug viewer user can watch variables and change values of variables
temporarily.

Navigation: View menu>debug viewer (for launching and closing)




              QTP Tool Window-Debug Viewer

5) Missing Resources

It can be used for showing missing resources those attached to current test such as
(recovery scenarios, library files etc).



                           www.GCREDDY.COM                                            13
For QTP Scripts & Other Information visit: www.gcreddy.com


   Navigation: View menu >missing resources (for launching and closing)

6) Information

   This pane shows syntax errors automatically during saving the test.

   Navigation: view menu> information




             QTP Tool Window-Information Pane

7) QTP Commands

   QTP Commands are available in 3 ways.


                          www.GCREDDY.COM                                 14
For QTP Scripts & Other Information visit: www.gcreddy.com


   1. Menu options
   2. Tool Bar options
   3. Short cut keys (for Some important operations only)




File menu: Through file menu user can create, save tests, open existing tests, export
tests in zip format.

Edit Menu: It provides editing options and renaming, deleting and splitting actions.

View menu: Through this menu we can launch and close, active screen, Data Table,
Debug viewer, information, missing resources etc.

Insert Menu: Through this menu user can inserting check points, out put values,
synchronizing points.

In this menu step generator available, using this user can generate recordable and non-
recordable scripts.

Through insert menu user can insert VB Script conditional and loop statements and
transaction points (Start and End).



                           www.GCREDDY.COM                                                15
For QTP Scripts & Other Information visit: www.gcreddy.com


Through insert menu user can create new actions, call existing actions and copy existing
actions.

Automation Menu:
This menu provides Record, Run options and Run setting options
Through this menu we can start normal recording, analog recording and Low level
recording.

Through this menu we can stop recoding, running and also we run tests.

Resources Menu:
This menu provides object repository and recovery scenarios options.
Through this menu we can create /modify/delete objects information and we can associate
repositories.
Through this menu we can create, modify and delete recovery scenarios.
Debug Menu:
This menu provides debug commands for step by step execution.
Through this menu we can insert/remove/break points.


Tools Menu:
This menu provides Tools settings option, view options and object identification
configuration.
Through this menu we can set tool options as well as test pane view options.
In this menu object spy option available, through this we can get object’s information.
(Properties and values)
In this menu Virtual object option available; through this option we can create virtual
objects.


Window Menu:
This menu provides QTP tool window style settings.

Help Menu:
This menu provides QTP help as well as VB Script help.
Through this menu we can contact technical support people and we can send feedback.
Through this menu we can check for updates and download or install directly.




                           www.GCREDDY.COM                                                 16
For QTP Scripts & Other Information visit: www.gcreddy.com


                         III) QTP Testing Process
Planning
   o   Analyzing the AUT
   o   Automation Test Plan Generation
   o   Automation Framework Implementation
   o   Generating/Selecting Test cases for Automation
   o   Collecting Test Data
   o   QTP Tool Settings Configuration
Generating Tests
   o   Recording
   o   Keyword driven methodology
   o   Descriptive Programming


Enhancing Tests
   o Inserting Checkpoints
   o   Inserting Output values
   o   Adding Comments
   o   Synchronization
   o   Parameterization
   o   Inserting Flow Control Statements
   o   Calling User defined functions
   o Generating Steps though Step Generator
   o   Inserting Transaction Points
   o Regular Expressions

Debugging Tests
   o Debug Commands & Break Points
   o   Step by step execution
   o   Watching Variables
   o   Changing values of variables


Running Tests
   o   Normal Execution
   o   Batch Execution
   o   AOM Scripting



                              www.GCREDDY.COM                   17
For QTP Scripts & Other Information visit: www.gcreddy.com

   o   Tests Running through framework
   o   Scheduled Execution


Analyzing Results
   o   QTP Result window
   o   Defining our own Results
   o   Exporting Results
   o   Deleting Results
Reporting Defects
   o   Manual Defect Reporting
   o   Tool based Defect Reporting
   o   Working with Quality Center


Analyzing the AUT

Before we begin creating a test, we need to analyze our application and determine our
testing needs.

First, determine the development environments in which our application controls were
developed, such as Web, Java, or .NET, so that we can load the required QuickTest add-
ins.

Then determine the functionality that we want to test. To do this, consider the various
activities that customers perform in our application to accomplish specific tasks. Which
objects and operations are relevant for the set of business processes that need to be
tested? Which operations require customized keywords to provide additional functionality?

While we are thinking about the business processes we want to test, consider how we can
divide these processes into smaller units, which will be represented by our test's actions.
Each action should emulate an activity that a customer might perform when using your
application.

As we plan, try to keep the amount of steps we plan to include in each action to a
minimum. Creating small, modular actions helps make our tests easier to read, follow, and
maintain.




                           www.GCREDDY.COM                                               18
For QTP Scripts & Other Information visit: www.gcreddy.com



                             Recording and Running:


In QTP there are 3 recording modes available for preparing Tests.

1. Normal Recording

It records User Mouse and Keyboard operations on AUT with respect to objects, but unable
to record continuous mouse operations like Digital Signatures, graphs, paints etc.

During recording QTP generates VbScript statements in Test Pane, Simultaneously it
stores objects information into object repository.

Navigation: Automation>Record
Or
Select Record option on automation toolbar
Or
Use short cut key (F3)

Steps for preparing a Test (through Recording):

   1.   Put AUT in base state
   2.   Select Record Option
   3.   It shows Record and Run Settings, Select type of Environment (Windows or Web)
   4.   Select Record Option

   (It shows two Options :
   1. Record and Run Test on any open window based applications
   2. Record and Run only on

   If we select first option it records on any opened application on Desktop.
   If we select Second option, it asks for the path of the AUT, After Providing the path it
   records only on that particular application.)

   5.   Click OK
   6.   Perform actions on AUT
   7.   Stop recording.
   8.   Save the Test

2. Analog Recording:

It records the exact mouse and keyboard operations. We can use this mode for recording
continuous mouse operations. It is not useful for recording normal operations why
because it does not generate steps for each operation, generates total user actions in a
Track File. The Track file is not editable.

Navigation:

   1. Keep tool under recording mode
   2. Automation >Analog Recording
               OR



                           www.GCREDDY.COM                                                19
For QTP Scripts & Other Information visit: www.gcreddy.com

   Use Short cut Key (Shift + ALT+F3)

Steps for preparing a TEST (through Analog Recording):

   1.   Launch AUT (or we can launch AUT through QTP)
   2.   Select Record option
   3.   Automation>Analog Recording
   4.   Analog Recording Settings Dialog box opens

   (In this Dialog box two options available.

   1. Record relative to the screen
   2. Record relative to the following window

   If we select first option QTP records User operations with respect to Desktop co-
   ordinates.
   If we select Second option, we have to show the window (AUT), after showing the
   Window it records with respect to that window co-ordinates.)

   5. Select any one option in the dialog box and click Start Analog record.
   6. It records User actions
   7. Stop Recording


3. Low Level Recording

It records some operations on Non-supported environments apart from Normal
operations.

This mode records at the object level and records all run time objects as window or
winobject Test objects.

Use Low Level Recording for recording in an environment not recognized by QTP.

Navigation:
   1. Keep tool under recording mode
   2. Automation >Low Level Recording

Steps for preparing a TEST (through Low Level Recording):


        1) Launch AUT (or we can launch AUT through QTP)
        2) Select Record option
        3) Automation> Low Level Recording
        4) Perform options on AUT
        5) Stop Recording
        6) Save the Test




                            www.GCREDDY.COM                                            20
For QTP Scripts & Other Information visit: www.gcreddy.com




                                   Object Repository

Object Repository:

It is a storage place of QTP where we can store the objects information and it also acts as
interface between the test script and the AUT in order to identify the objects during
execution.

Object:

Object is something, which has structure and properties.

Software objects:

We call windows, WebPages, buttons, edit boxes, check boxes etc.. as software objects.

Types of Object in QTP:

There are four types of object available in QTP.

   1.   Run time objects
   2.   Test objects
   3.   Utility objects
   4.   Automation objects/User defined objects.



Run time objects: The objects present in the AUT. Ex: Buttons, links, etc…

Test Objects: References of Run time objects. Ex: WinEdit, WinButton, WebButton, Link,
etc…

   Note:
   Test objects names vary from one environment to another.
   Ex:
   Run time objects     Test objects in     Test objects in VB        Test objects in web
                        windows             Environment               Environment
                        Environment
   buttons              WinButton           VBButton                  WebButton
   Edit box             WinEdit             VBEdit                    WebEdit
   Check box            Wincheckbox         Vbcheckbox                Webcheckbox



Utility objects

   They are QTP reserved objects used for testing and result reporting.
   Ex:
   1. SystemUtil for launching/closing the application.
   2. Reporter for defining results.



                            www.GCREDDY.COM                                              21
For QTP Scripts & Other Information visit: www.gcreddy.com

   3. Services for inserting transaction points
   4. Environment for using environment variables


Automation objects/User defined objects

User can create objects; those can be used for performing specific operations. Ex:
Creating objects in file system object class, adodb.connection class, dictionary object
class, excel. Application class etc.


There are two types of repository available in QTP.
   1. Local repository (.MTR extension)
   2. Shared repository(.TSR extension)

Local Repository:

   QTP creates a Local Repository for every action automatically during Recording. That
   cannot be shared among tests.

   User can add some more objects to Local repository

   User can perform rename, delete operations in local repository. As it is QTP internal
   file user no need to save modifications.

   Navigation: Resource menu>object repository (Short cut key Ctrl+R)




                            www.GCREDDY.COM                                                22
For QTP Scripts & Other Information visit: www.gcreddy.com




                                QTP- Local Repository

Shared Repository:

User (Test Engineer) creates shared repository by adding objects. That can be shared
among number of tests.
Using this method user can perform modifications on objects easily.

                          Operations on Object Repository

Adding objects

a. Local Repository:

   Navigation: open local repository (resource menu>object repository)
   >objects>Add objects to Local>show the object>click ok
   (No need to save separately, it saves automatically)

B. Shared Repository:

   Navigation: Resource menu>object repository manager>object>Add objects>show the
   window/object>click ok



                           www.GCREDDY.COM                                             23
For QTP Scripts & Other Information visit: www.gcreddy.com


           o   Selected object only
           o   Default object types
           o   All objects types
           o   Selected object types

(If we select first option it stores Selected objects only, if we select second option it stores
all default objects, if we select third option it stores All objects including static objects, if
we select fourth option, we have to select object classes then it stores that class objects,
we can select more than one class also.)


Renaming objects

a. Local Repository:

Resources > object repository >select object and right click >choose rename option
>modify the name>release the mouse.>close repository

b. Shared Repository:

Resources >object repository manager>file>open>browse path of the repository file
>file>enable editing>select object &Right click>choose rename option>modify the name
> release mouse>save the file & close repository manager.

Deleting objects

a. Local Repository:

Resources > object repository >select object and right click >choose delete option
>confirm deletion>. >close repository

b. Shared Repository:

Resources >object repository manager>file>open>browse path of the repository file
>file>enable editing>select object &Right click>choose delete option>confirm the deletion
>save the file & close repository manager.


Associating objects repositories to an action

Resources>Associate repositories>click add icon (+)>browse path of the
repository>Associate with an action>click ok

Merging Repositories

Resources > object repository manager>tools>object repository merge tool >browse path
of the first repository> browse path of the second repository>click ok>click close>save
the merged repository>close the repository manager.

Note: After merging also, source repository files will be available, if we do not want source
files we can delete.



                             www.GCREDDY.COM                                                  24
For QTP Scripts & Other Information visit: www.gcreddy.com

Defining new test objects

Navigation: Object>Define new test object >Select Environment>Select Class of the
object>Enter name of the object>Click Add>click close>Select object >select property
name>enter value (like this select one by one properties and enter values)>save

Note: This feature can be used for preparing tests before the AUT is ready.

Spying objects

For getting objects information, (Test objects names, property & Values) QTP is providing
a feature called Object Spy, using this we can get objects information.

Navigation>Tools>object spy>take hand icon & Show the object>get information (Object
Spy shows the specific objects all available properties with their values)

Note: As Object spy is an important feature, it can be available in 3 Areas.(1. In tools
Menu 2. In local repository 3. In Repository manager)

View Options

Locate in Repository

   This feature can be used for identifying objects from application to repository.
   Navigation: View>Locate in repository >show the object>click Ok>it locates specified
   object in the repository.

Highlight in Application

   This feature can be used for identifying objects from repository to application.
   Navigation: Select object in the repository >view>highlight in application>it highlights
   specified objects in the application.


Exporting Repository to an XML file

We can export our repository file to an xml file.

Navigation: File >export Test objects to XML Enter the file name and Save with xml
extension.

Importing Repository from XML file.

We can import XML file to our repository.

Navigation: File>import from XML >browse path of the XML file >it loads objects.

Note: The purpose of this feature is Editing objects information outside of the QTP




                            www.GCREDDY.COM                                                25
For QTP Scripts & Other Information visit: www.gcreddy.com



                                             Methods

Activate: It activates dialog boxes/Windows

Syntax: Object hierarchy. Activate

Ex:
      Dialog(“Login”).Activate
      Window(“Flight Reservation”).Activate


Click Method: It clicks on an object (Buttons)
    Syntax: Object hierarchy. Click
    Ex:
    Dialog(“Login”).Winbutton(“ok”).click

Close Method: It closes the window,Dialog box, Browser window etc.

      Syntax: Object hierarchy. Close

      Ex:

      Window(“Flight Reservation”).Close
      Browser(“Browser”).Close

      DBL CLICK: It Double clicks the object.

Set Method: It can be used in three ways.

      a. For setting the value of an edit box
      Syntax: Object Hierarchy. SET “Value”
      Ex: Dialog (“Login”).WinEdit(“Agent Name”).Set “asdf”

      b. Selecting a Radio Button
      Syntax: Object Hierarchy. Set
      Ex: Window("Flight Reservation").WinRadioButton("Business").Set

      c. Selecting/Deselecting check boxes
      Syntax:object Hierarchy.Set “ON/off”

      Ex: Window ("Flight Reservation"). Dialog("Open Order").WinCheckBox("Order
      No.").Set "ON"


Select Method:


      It is used for selecting an item from a combo box or list box.
      Syntax: Object hierarchy.select “item”

      Ex:



                              www.GCREDDY.COM                                      26
For QTP Scripts & Other Information visit: www.gcreddy.com

A. Window("Flight Reservation").WinComboBox("Fly From:").Select "London"
B. Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "12572

GetVisibletext: It returns Text from the specified area.

Syntax: Variable =object hierarchy.getvisibletext

Ex:
x=Window("Flight Reservation").WinComboBox("Fly From:").GetVisibleText
msgbox x

GetRoproperty:
It returns current object property value. It can be used for getting any object’s, any
property value.
Syntax: Variable = object hierarchy.getroproperty (“property name”)
Ex: x=Window("Flight Reservation").WinEdit("Tickets:").GetROProperty ("width")
msgbox x

Navigate Method:
It opens a specified URL in the Browser.
Syntax: object hierarchy.navigate “URL”
Ex: Browser("Yahoo!").Navigate "http://www.google.co.in"

Getitemscount: It returns number of items in a combobox.

Syntax: Variable=object hierarchy.getitemscount
Ex: x=Window("Flight Reservation").WinComboBox("Fly From:").GetItemsCount
msgbox x

Getcontent: It returns all items from a combobox.
Syntax: variable=object hierarchy.GetContent
Ex: x=Window("Flight Reservation").WinComboBox("Fly From:").GetContent
msgbox x

Exist property: It checks whether the object is available or not.
Syntax: Object hierarchy.exist(time in seconds)
Ex: Window("Flight Reservation").Exist(5)




                            www.GCREDDY.COM                                              27
For QTP Scripts & Other Information visit: www.gcreddy.com


            Descriptive Programming/Programming Descriptions


Providing objects information directly into the test script is called Descriptive
Programming.

These scripts can be executed faster than repository based scripts.
Descriptive programming is basically 2 types.
   1. Static Programming
   2. Dynamic Programming

Static Programming: In this style of script generation, we provide objects information
directly into the script.

Ex:
      Invokeapplication "C:Program FilesHPQuickTest
      Professionalsamplesflightappflight4a.exe"
      dialog("text:=Login").Activate
      dialog("text:=Login").Winedit("attached text:=Agent Name:").Set "asdf"
      dialog("text:=Login").Winedit("attached text:=Password:").Set "mercury"
      dialog("text:=Login").Winbutton("text:=OK","width:=60").Click

Note:
      1. Dialog, WinEdit and WinButton – Test Objects
      2. text, attached text - Property names
      3. Login, Agent Name:, Password:, OK - Property values or Logical Names of the
         Object
      4. Activate, Set, Setsecure, Click - Methods

Note2:

If we feel one property information is not sufficient for recognizing the object uniquely,
then we can provide more properties information by separating with commas.

Note 3:

If we want to get objects information (Test objects, properties and values), we can use
object spy feature. This feature is available in Tools Menu, in local repository and in
repository manager.


                                  Dynamic Programming:

In this style of script generation, first we create description objects, provide properties
information and use description objects in the test script.

Creating Properties Collection Objects

Set   oLogin=description.Create
Set   oAgent=description.Create
Set   oPassword=description.Create
Set   oOk=description.Create



                             www.GCREDDY.COM                                                  28
For QTP Scripts & Other Information visit: www.gcreddy.com


Entering Properties Information into Objects

oLogin("text").value="Login"
oLogin("width").value=320
oLogin("height").value=204
oAgent("attached text").value="Agent Name:"
oPassword("attached text").value="Password:"
oOk("text").value="OK"

Generating Tests using Properties collection Objects

Invokeapplication "C:Program FilesHPQuickTest
Professionalsamplesflightappflight4a.exe"
Dialog(oLogin).Activate
Dialog(oLogin).Winedit(oAgent).Set "asdf"
Dialog(oLogin).Winedit(oPassword).Set "mercury"
Dialog(oLogin).Winbutton(oOK).Click

Note1: Create Description objects and put into one library file, by associating that library
file, we can generate tests.

Note2: Dynamic programming is some difficult in preparation than static programming but
maintenance is very easy.



                               Enhancing Tests

After generating the basic test, we have to enhance the test in order to Test the AUT with
respect to requirements.

There are several methods available in QTP for enhancing the TEST.

   1. Inserting Check Points
   2. Inserting Output Values
   3. Adding Comments
   4. Inserting Flow Control Statements
   5. Synchronization
   6. Parameterization
   7. Generating Steps through Step Generator
   8. Inserting Transaction Points:(Start and End)


Inserting Check Points:

   Check point is a verification point, it takes expected result from the user and compares
   with actual results during execution and provides test results.

   There are 11 check points available in QTP:

   1. Standard check point



                            www.GCREDDY.COM                                                29
For QTP Scripts & Other Information visit: www.gcreddy.com

2.    Text check point
3.    Text area check point
4.    Bit map check point
5.    Data base check point
6.    Accessibility check point
7.    XML Check point (from application)
8.    XML Check point (from resource)
9.    Page check point
10.   Image checkpoint
11.   Table checkpoint

Note 1: From 6 to 11 checkpoints are only for Web.
Note 2: From 9 to 11 checkpoints are hidden checkpoints, we can insert these
checkpoints through standard checkpoint.


 1. Standard Checkpoint: It checks object property values. We can use this checkpoint
for checking any property value.

Navigation1(Inserting standard checkpoint)

: Keep tool under recording mode>place cursor in desired location>Insert arrow check
point>Standard checkpoint>Show the object (which is result window)>click
okay>select property and enter expected results&click ok and stop recording.

Navigation 2 (editing standard checkpoint)

Select checkpoint statement and right click >choose checkpoint properties
option>modify the value>click ok.

Navigation 3 (Deleting standard checkpoint)
Select checkpoint statements and right click>choose delete option.

Inserting Standard check points through active screen:

 View>Active Screen>place cursor in desired location>Place mouse pointer on active
screen&right click>choose insert standard checkpoint option>click ok>enter expected
result>click ok

Note: Inserting Standard check points through keyword view same as in expert view.




Note: We can insert standard checkpoints in 3 ways.

1.    Through expert view, 2. Through keyword view, 3. Through Active screen.

2.    Text Checkpoint: It checks object’s text property value in different ways.

Navigation: keep tool under recording mode>Insert check point>text
checkpoint>Show the object >click ok>Select options




                         www.GCREDDY.COM                                           30
For QTP Scripts & Other Information visit: www.gcreddy.com

(Match case, ignore spaces, exact match, text not displayed.)

We can select one or more options>click ok & stop recording.

3.   Text Area Checkpoint: It checks the text area present in the application.

Navigation: Keep tool under recording mode >Insert arrow checkpoint>Text area
checkpoint>Mark the area of text >select one or more options


(Match case, ignore spaces, exact match, text not displayed.)

Click ok and stop recording.

4.   Bitmap checkpoint: It compares bit maps, we can compare complete bit maps as
     well as part of the bit maps.

Navigation: Keep tool under recording mode>insert >checkpoint>bitmap
checkpoint>show the bitmap>click ok>select “check only selected area” option if we
want to compare part of the bitmap>click ok>stop recording.

5.   Database checkpoint: It checks Content of the back end database.

Navigation: Insert>checkpoint>database checkpoint>choose “specify SQL statement
manually”option>click next >click create>select machine data source>Select
DSN(QT_flight32)>click ok>enter SQL statement (select * from orders)>finish>click
ok.

Note: here we do not need to put on recording mode and we do need AUT since data
is from backend.

6. Accessibility check point: It checks whether the webpage in our web application is
developed according to W3C (world wide web consortium) rules and regulations or
not.

 It is a configurable checkpoint, according to our requirements, we can customize.
 Configuring accessibility checkpoint: Tools>options>web>adavanced>check/uncheck
items >click apply>click ok

Navigination: Keep tool under recording mode with web environment
>insert>checkpoint>accessibility checkpoint>show the webpage>click ok>click
ok>stop recording.

Result Criteria: 1. If item is available but not according to W3C rules then fail.
1. If an item is available, according to W3C rules then Pass.
2. If an item is not available then result would be pass

7.XML Check point (from application)

It checks content of the XML file.

Navigation: Keep tool under recoring mode in web environment>insert >checkpoint
(from application)>show the xml pages>click ok>stop recording.


                         www.GCREDDY.COM                                             31
For QTP Scripts & Other Information visit: www.gcreddy.com


9. XML Check point (from resource)

It checks content of the XML file.

Navigation: Insert>checkpoint>xml checkpoint (from resource)>browse path of the
XML File >click ok>click ok.

Note: 1. If XML file is an individual and path available, then we can go for inserting
xml checkpoint from resource.

Note: 2. If XML file is part of web application, separte path is not available then we can
choose inserting XML checkpoints from application.

10. Page checkpoint: It checks number of links, images available in a web page.

It is a hidden checkpoint, we can insert this through standard checkpoint.

Navigation: Keep tool under recording mode with web environment
>insert>checkpoint>Standard checkpoint>show the page>click ok>click ok>stop
recording.

11. Image checkpoint: It checks Image property values.

Navigation: keep recording mode with web environment
>insert>checkpoint>standardcheckpoint>show the image>select image>click ok>click
ok>stop recording.

12. Table checkpoint: It checks content of the web tables.

Navigation: Keep tool under recording mode under web
environment>insert>checkpoint>standard checkpoint>show the table>click ok >stop
recording.


Inserting Output Values:

It is a step in which one or more values are captured during execution.

The values can later be used as input at a different point in the run session or we can
use as input for another test.

It is stored in run time data table; it is located in QTP result window and can be
retrieved later.

Types of Output Values:

1.   Standard output value
2.   Text output value
3.   Text area output value
4.   Database output value
5.   XML output value (From Application)
6.   XML output value (From Resource)


                        www.GCREDDY.COM                                                  32
For QTP Scripts & Other Information visit: www.gcreddy.com



   A. Standard output value: We can use standard output values to output the properties
   values of most objects.

   Navigation: Keep tool under recording mode >Insert >output value>standard output
   value>show the object>click ok>select property>modify the column name (if
   required)>click ok>click ok>stop recording.

   B. Text output value: We can use Text output values to output text strings displayed in
   an application. When creating a text output value we can output a part of the objects
   text and we can also specify text before and after options.

   Navigation: Keep tool under recording mode>Insert>output value>text output
   value>show the text>select one of the option(output text/text before/text after)>click
   modify if you want to change the column name>click ok>click ok.>check in runtime
   table after running it.

   C. Text Area output value: We can use text area output values to output text strings
   displayed within a defined area of the screen.

   Navigation: keep tool under recording mode>insert>outputvalue>text area output
   value>Mark the text area>click modify the column name if necessary>click ok>again
   click ok>check in run time table after running it..

   D. Database output value: We can use Database output values to output the value of
   the contents of database cells.

   Navigation: Insert>outputvalue>Database output value>choose specify SQL
   statements manually>click next>click create>Select Machine Data source>Select
   Driver (QT_flight32)>click ok>enter SQL statement(select *from orders)>click
   finish>select datacells>click ok>Run and it will capture and see the results in run time
   table.

   E. XML output value(from application): we can use XML output values to output the
   values of XML elements in XML documents.

   Navigation: Keep tool under recording mode with web environment>Insert>output
   value>XML output value from application>Show the XML document>select
   elements>click ok>stop recording.

   F. XML output Value (From Resource) we can use XML output values to output the
   values of XML elements in XML documents.

   Navigation: Insert>output value>XML output value from resource>browse path of the
   XML file >click ok>select elements>click ok.


Adding Comments:
Purpose of Comments:
   o For making the script understandable
   o For making the Script Disable from execution




                           www.GCREDDY.COM                                                33
For QTP Scripts & Other Information visit: www.gcreddy.com

Syntax:
1. Use Apostrophe (‘) before the statement
2. Use REM Command with single space before the statement

Comment a Block of Statements:
Navigation: Select block of statements >edit menu>advanced>comment block

Or
After selecting block of statements use shortcut key Ctrl+M


Uncomment a block of statements:

Navigation: Select comment block>Edit menu> Advanced>Uncomment block

Or
After selecting comment block, Use shortcut key ctrl+shift+M

Inserting Flow Control Statements:

QTP adapted Vbscript engine for applying programming logic to tests. We can insert
Vbscript conditional statements and loop statements for applying the logic.

In Vbscript there are 2 types of conditional statements and four types of loop
statements available.

Synchronization
It is a process of matching the speeds of both QTP and AUT in order to get proper
execution and results.

Where Synchronization is required: During test execution QTP gives instructions one
by one with same speed, but AUT takes less time for some operations execution and
more time for some operations execution, that time we may not get proper execution
and results. In order to get proper results in between QTP & AUT synchronization is
required.

There are several methods available in QTP for synchronization.

1.   Inserting Wait statements.
2.   Inserting Synchronization points.
3.   Increasing Tool default synchronization time.
4.   Sync Method (Only for WEB)


Inserting Wait Statements: We can insert wait statements in our test in order to make
QTP to wait until AUT completes current operation.

Syntax: Wait(time in seconds)

Note: If we insert wait statements QTP waits up to maximum time even though
operation is completed.

Inserting Synchronization point:


                         www.GCREDDY.COM                                             34
For QTP Scripts & Other Information visit: www.gcreddy.com

Place cursor in desired location>keep tool under recording mode>Insert
menu>Synchronization point >show the object >click ok>select property name &
Value(True)>enter time in Milli seconds>click ok>Stop recording.

Note: if we insert Synchronization points, it does not wait up to maximum time, after
completion of the current operations, it goes to next step immediately.

Syntax: object hierarchy.waitproperty “property name”,value,time in milli seconds.

Increasing Tool default synchronization time:
Navigation: File>settings>run tab>increase object synchronization time out>apply>ok

Note: If we increase QTP tool default time that can be applied for all statements in the
test, but QTP does not wait up to maximum time unnecessarily, After completion of
one statement execution it goes to next statement immediately.

Sync Method: (only for WEB)

Waits for the browser to complete current navigation.

Syntax: Object Hirearchy.Sync

Ex: Browser("Yahoo! Toolbar").Page("Yahoo! Toolbar").Sync

Selecting an appropriate Method:

1. Suppose in our test one or more statements only are taking more time for
   execution then selecting “Inserting synchronization method” is better.
2. Suppose in our test more statements are taking more time for execution then
   selecting “increasing tool time out” .
3. Above two are local features but wait statement is Vbscript feature, even though
   some drawbacks are there in using wait statement, it is better to use wait
   statement in functions.



Inserting Transaction Points:(Start and End)

We can insert Transaction points for measuring Transaction time.
It is a performance concept but QTP supports measuring transaction time per user
only.

Syntax:
Services.StartTransaction "name of transaction"
-------
statements
---------
--------
services.EndTransaction "name of the transaction"
Note: We can insert multiple transactions points in a test.




                        www.GCREDDY.COM                                               35
For QTP Scripts & Other Information visit: www.gcreddy.com

Parameterization

Passing parameters, through this concept we can pass multiple values.

We use parameterization in Data Driven Testing.

Data Driven Testing: Testing the Same operation with multiple sets of test data.

Types of Parameterization: We can parameterize tests in several ways.

1.   Through Loop Statements
2.   Dynamic Test Data Submission
3.   Through Data Table
4.   Fetching Test Data directly from External files (Flat files & Spreadsheets)
5.   Fetching Test Data directly from Databases (MSAcess, oracle etc).
6.   Getting Test Data from front end objects.



1. Through Loop Statements: We can use loop statements for passing sequential
numbers & Logical Numbers.

Note: We can’t generate Strings.

For orderno=1 to 10 step 1 ' for one increment step keyword is not mandatory
Window("Flight Reservation").Activate
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 orderno
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Next


2.Dynamic Test Data Submission: Through Loop Statements we can give strings also
but every time user has to enter data.

For x=1 to 3
Agent =inputbox("enter an Agent Name")
Password=inputbox("enter a password")
invokeapplication "C:Program FilesMercury InteractiveQuickTest
Professionalsamplesflightappflight4a.exe"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set Agent
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure password
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close
Next


3. Through Data Table: QTP adds one data table (Spreadsheet) for every test, we can
use Data Table for Data Driven Testing.


                         www.GCREDDY.COM                                           36
For QTP Scripts & Other Information visit: www.gcreddy.com


It has 3 types of usage .

       a.   Entering test data directly into data table and use
       b.   Importing test data from external Flat files
       c.   Importing test data from external Spread sheets
       d.   Importing test data from Data bases.

       A. Entering test data directly into data table and use.

       Steps: Generate the basic test>open data table(View>Data Table)

       Click on column header>enter the name of the field (like this we can create
       number of columns) > Enter Data>connect the data to test

      (variable=datatable(“column name”, Sheet id)
Example: agent=datatable(“agent”,1)
             Pass parameters.)

Run the test.

Agent = Datatable("Agent",1)
pwd=Datatable ("Password",1)
invokeapplication "C:Program FilesMercury InteractiveQuickTest
Professionalsamplesflightappflight4a.exe"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set Agent
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure pwd
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close


b. Importing test data from external files:

Open Data Table (view>Data table)>place mouse pointer on data table and right
click>file>import from file>Click ok>Browsw path of the file(it imports data from the
flat file)

Connecting Test Data to QTP Test as above and run the test.

c. Importing test data from external Spread sheets:

Open Data Table (view>Data table)>place mouse pointer on data table and right
click>file>import from file>Click ok>Browse path of the excel sheet (it imports data
from the excel sheet)

Connecting Test Data to QTP Test as above and run the test.

D. Importing test data from Data bases: Through Data table we can import Test Data
from Data bases, but first we have to create /get the DSN(Data source Name)& we
have to use SQL Commands.




                         www.GCREDDY.COM                                                37
For QTP Scripts & Other Information visit: www.gcreddy.com

   1. Creating a Test Database: open MS Access (or we can use any other database).

   Start programs>MS Office>MS Access>file >new>Select blank Database>enter name
   of the database>Save with mdb extension.

   Creating Tables: Select Create table in design view>Enter field name(Agent)and Select
   data type(text) Like this we can create number of fields>save&enter table name.

   Entering Data into Tables: Select table>enter the data.


   Creating DSN & importing data

   Navigation: view>data table>Place mouse pointer on Data table>sheet>import>from
   database(Database query wizard opens)>choose ‘specify SQL statements
   manually>click next >click create>click new>select driver type>click next >browse
   path to store> enter DSN Name>Click Save>click next>click finish>select>browse the
   database& select>click ok>click ok>select DSN>click ok>enter SQL statement (select
   *from login)>click finish.

   Note: DSN Creation is one time activity, by using the DSN we can get data for number
   of tests.


   4. Fetching Test Data directly from Flat files

Dim fso, myfile
Set fso=createobject("scripting.filesystemobject")
Set myfile=fso.opentextfile("d:trigun.txt",1)
myfile.skipline

While myfile.atendofline <> true
      x=myfile.readline
      S=split(x,"@")

SystemUtil.Run "C:Program FilesMercury InteractiveQuickTest
Professionalsamplesflightappflight4a.exe","","C:Program FilesMercury
InteractiveQuickTest Professionalsamplesflightapp","open"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set s(0)
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure S(1)
Dialog("Login").WinEdit("Password:").Type micReturn
Window("Flight Reservation").Close
Wend

Fetching Test Data directly from Excel Sheets

Fetching Test Data directly from Databases

option explicit
Dim con,rs
Set con=createobject("adodb.connection")


                           www.GCREDDY.COM                                           38
For QTP Scripts & Other Information visit: www.gcreddy.com

Set rs=createobject("adodb.recordset")
con.provider=("microsoft.jet.oledb.4.0")
con.open "C:Documents and SettingspoojaMy Documentstrigun.mdb"
rs.open "select * from login",con
do until rs.eof=true
SystemUtil.Run "C:Program FilesMercury InteractiveQuickTest
Professionalsamplesflightappflight4a.exe","","C:Program FilesMercury
InteractiveQuickTest Professionalsamplesflightapp","open"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set rs.fields ("agent")
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure rs.fields("password")
Dialog("Login").WinEdit("Password:").Type micReturn
Window("Flight Reservation").Close
rs.movenext
loop

                                   Debugging the TEST


Debugging is a process of executing the script or a program in a User designed fashion
with some temporary break points in order to identify the errors.

For debugging, QTP is providing debug commands and breakpoints.

Debug Commands:

   1. Step Into: (short cut key F11)
   a. It starts execution
   b. It executes one statement at a time.
   c. If it is function call, it opens the function, after that it executes one statement at a
      time.

   2. Step Over (Short cut key F10)


          e. It executes one statement at a time after execution starts
          f. It executes all functions statements at a time

Note: After opening the function, if we use step over it executes one statement at a time
only.

   3. Step Out (shift +F11)

   It executes all remaining statements in a function at a time.

   Ex: Dim a,b,c
   a=100
   b=200
   c=a+b
   msgbox c
   msgbox "hello"



                            www.GCREDDY.COM                                                 39
For QTP Scripts & Other Information visit: www.gcreddy.com

Call hyderabad
msgbox "bye bye"

Note: Create a script and work on it
Break Point:


This feature is used for breaking the execution temporarily.

Navigation:

Place cursor in desired location >Debug menu>Insert/Remove break point

Or

Use short cut key (F9)

Or
Place mouse pointer before the statement and click.

Note: If we want to execute Some part of the Test Script at a time and some other
part of the test script step by step, there we can use breakpoints.


Debug viewer Pane:

It is used for viewing, modifying or setting the value of the variables during the
execution break with the help of 3 Tabs.

       1. Watch
       2. Variables
       3. Command


       Note: Through Debug Viewer Pane, We can watch variables whether the
       variables are taking correct values or not at a specific point of time. We can
       change Values of Variables temporarily.

       Ex :
       Dim x,y,z
       x=10
       y=20
       z=x+y
       msgbox z
       msgbox "Hello"
       x=35
       y=67
       z=x*y
       msgbox z
       msgbox "bye bye"

       Navigation: debug viewer>Use step into feature.




                         www.GCREDDY.COM                                                40
For QTP Scripts & Other Information visit: www.gcreddy.com


                               Running the Test / Executing the Test


   1. Normal execution/ General execution (Executing one test at a time)
   2. Batch execution/Batch Testing
   Executing a group of tests at a time is known as batch execution. For performing batch
   execution QTP is providing a separate tool called test batch runner.

   Steps for batch testing:

   1. Prepare individual tests and run once.
   2. Open Test batch runner tool and form batches.
   3. Execute Test batches from Test batch runner.


   Forming a Test Batch:

   Launch Test batch runner.

   Navigation: Start>program>quicktest professional>Tools>Test Batch
   Runner>File>new>batch>add>browse path of the test (like this add number of
   tests)>save with MTB extension (Module test batche)>close test batch runner.

   Executing a TEST Batch.

   Open Test Batch Runner Tool

Navigation: File>open>browse path of the test batch>batch>run

Note: Test batch runner launches QTP Tool, QTP runs Tests one by one.

Note: Allowing other products to run tests.
Navigation: Tools>Options>Run>check allow other mercury products>apply & Ok

Executing partial Test Batch

Open Test Batch runner >open Test Batch>Select or deselect tests>run test batch.

Note: QTP does not provide Batch wise test results. We have to view Test wise results
through Test Result viewer.

   3. AOM Scripting (Automation Object Model)

   We can use QTP automation object Model to write scripts that automate our QTP
   operations.

   QTP automation object model provides objects, methods and properties that enable us
   to control QTP from another application.

   We can use Scripting languages or programming languages such as VBscript, Java
   script or VC++, .Net for automating QTP operations.



                              www.GCREDDY.COM                                           41
For QTP Scripts & Other Information visit: www.gcreddy.com

   Ex:
   option explicit
   Dim qtApp,qtTest
   Set qtApp=createobject ("quicktest.application")
   qtApp.Launch
   qtApp.visible=True

   qtApp.open "C:Documents and SettingsadminMy Documentslogin"
   Set qtTest=qtApp.Test
   qtTest.run
   qtTest.close

   qtApp.open "C:Documents and SettingsadminMy Documentsopen order"
   Set qtTest=qtApp.Test
   qtTest.run
   qtTest.close

   qtApp.quit

   Notes: Set is for statement, QtApp is variable, Createobject is for function,
   “quicktest.application” is used for class value
   Launch is used for method.

   4. Executing Tests through Framework
   5. Scheduled execution

   Navigation: Start>Settings >control panel>Select on scheduled tasks>Click add
   scheduled task>click next>Select Application as quick test professional>Click
   next>Type name of the task AOM.Vbs>select the schedule>click next>enter time and
   date>click next>enter system name and password if required>click next>click Finish.

   6. Analyzing the results:

   a. Test result viewer: QTP is providing Test Result Viewer for viewing and exporting
      test results.

   Navigation: Start>Programs>Quick Test Professional>Test Result Viewer>File
   >open>Browse path of the test>Select Result>click open.
                           Or
   From QTP Tool window: Automation menu>results>browse path of the test> Select
   Result>click open.
                           Or

Click result icon on Automation tool bar>

B. Deleting Test Results: For Deleting test results QTP is providing a separate Tool called
Test Result Deletion Tool.

Navigation: Start programs>quick test professional>Tools>Test result Deletion
tool>browse path of the test>Select result>click Delete>click close.

C. Result Reporting : From QTP result window.



                            www.GCREDDY.COM                                               42
For QTP Scripts & Other Information visit: www.gcreddy.com

Navigation: File >export to HTML file>click export>browse path of the location>save.

Note: In QTP 10.0 , Apart from HTML format DOC, XML & PDF formats also available.

                                     Reporting Defects


Functional Automation        Defect Management             Tasks
QTP                          Manual                        After analyzing the results,
                                                           open company prescribed
                                                           defect report template,
                                                           enter defect details and
                                                           send
QTP                          Any Tool like BugZilla or     After analyzing the results,
                             issue –Tracker or PR –        open the TOOL, open the
                             Tracker, etc.                 defect reporting template,
                                                           enter defect results and
                                                           send
QTP                          QC (Quality Center)           In between QTP & QC back
                                                           to back integration. We
                                                           can send defects directly
                                                           from QTP result window.




                           Other QTP Features
Actions

We divide our test into actions to streamline the process of testing.

Purpose of Actions:

For understandability
For reusing components


Types of Actions:

Non Re usable actions
Re usable actions
External actions


Operations on actions:


   •   Creating Actions

   •   Splitting Actions

   •   Renaming Actions




                            www.GCREDDY.COM                                               43
For QTP Scripts & Other Information visit: www.gcreddy.com


   •   Deleting Actions

   •   Calling an Action

   •   Copying an Action

   •   Making an Action Reusable/Non Reusable


Creating an action:
   Insert>call to new action>enter name of the action>click ok

    Steps:
   1. Create required actions(ex login, insert,delte)
   2. Prepare Scripts for those actions.


   B. Splitting an action:

   Navigation: Place cursor in desired location>Edit menu>action>split action>Enter
   Action 1 name & action 2 name.

   Steps:
   1. Generate total test in the default action
   2. Split into meaningful actions.

   Note: At a time we can split one actions into 2 actions.


   C. Renaming actions: Select desired action in action drop down box> edit
   menu>action>rename action>modify the name>click ok.

   D. Deleting Actions: Select desired action in action drop down box>edit
   menu>action>delete action>confirm deletion.

   E. Calling an action: Insert>call to existing action>browse path of the test>select
   desired action>click ok.

   Note: U can’t edit

   F. Copying an action: Insert>call to copy of action>browse path of the test>select
   desired action>click ok.

   Note: we can edit this action.

   G. Making an action reusable: Select Non Reusable action >edit >action>action
   properties>check reusable action check box >click ok.




                                    Regular Expressions




                             www.GCREDDY.COM                                             44
For QTP Scripts & Other Information visit: www.gcreddy.com

We use regular expressions whenever object’s properties values are changing
dynamically.

Navigation: Open object repository >select the object>select the property value>click
configure>check regular expression >enter expression [0-9] close repository.

Note:
1. Always-regular expression we use brackets.
2. [A-Z]
3. [a-z]
4. [A-Z] [a-z] we can also use two expressions together

[0-9] for one to 9 digits this is how we use
[0-9]*for 2 digit numbers to be considered.

For example use fax order


Functions:

Functions are Vbscript features; we use these for reusing components.

Vbscript Procedures:

In Vbscript there are 2 kinds of procedures available.

1. Sub procedures
2. Function procedures

A. Sub Procedures: Sub procedure performs a task(s) but cannot return a value.

Syntax: SUB    Name of the procedure(arguments)

Statements

End Sub

Note: Arguments are optional , We can give number of arguments by separating with
commas. Ex: (a,b,c)

Creating a Sub procedure
Open an editor (notepad)
Prepare test script
Save as Dot.vbs file

Ex:

Sub login
  Invokeapplication "C:Program FilesHPQuickTest
Professionalsamplesflightappflight4a.exe"
dialog("text:=Login").Activate
dialog("text:=Login").Winedit("attached text:=Agent Name:").Set "asdf"
dialog("text:=Login").Winedit("attached text:=Password:").Set "mercury"


                         www.GCREDDY.COM                                           45
For QTP Scripts & Other Information visit: www.gcreddy.com

dialog("text:=Login").Winbutton("text:=OK","width:=60").Click

End Sub

Associating a procedure to QTP.

Navigation: File >settings>Resources>Click add icon>browse path of the library
file>click apply>click ok
Or
Executefile “path of the library file” C:Documents and
SettingspoojaDesktop/login.vbs”
Calling a procedure:

Call procedure name (ex Call login)

Function Procedure (it returns a value)

Function trigun(a,b,c)
  res=(a+b+c)
  trigun=res
  End Function
  x=trigun(100,200,300)
  msgbox x




                             Environment Variables

These are global variables; if you want to use some variables globally (From number of
tests) declaring as global variables is better. If we declare as local variables in number
of tests, modifications are difficult.


Types of Environment variables:

1. Built in variables: These are system defined variables, we can access from all tests
   but these are designed as read only.
2. User defined variables: Variables that we predefine in the active external
   environment variables file. We can create as many files as we want and we can
   change values of variables.


Usage of environment variables:

Syntax: Variable = Environment(“environment variable name”)

Ex: X=Environment (“ActionName”)
Msgbox x

Example Script:




                        www.GCREDDY.COM                                                46
For QTP Scripts & Other Information visit: www.gcreddy.com

ProductDir =environment ("ProductDir")
app= "samplesflightappflight4a.exe"

Systemutil.Run ProductDir & app
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "kajal"
Dialog("Login").WinEdit("Password:").SetSecure
"4b3c86f2107ff565cc195ba6c24739091b656407"
Dialog("Login").WinButton("OK").Click


   Creating user defined environment variables:

   Navigation: File>settings>environment>select variable type as user defined>click add
   icon (+)>enter variable name & Value>click ok (like this we can create number of
   variables)>click export >browse path & enter file name, save with xml
   extension.>click ok.

   Associating environment variable file:

   Navigation: file >settings>environment >select variable type as user defined>check
   “load variables and values from the external file”> browse path of the xml file >click
   apply & ok.
   Or
   We can load environment file directly
   Environment.loadfromfile”path of the xml file”

   Usage of user defined environment variables:

   Associate environment file to current test:
   Variable = Environment (“Variable Name”)

   X=environment (“city”)
   Msgbox x


   Modifying Environment files:

   Select XML file>open with notepad>modify the values>Save.


                            Virtual object configuration

   It is a process of making the QTP to treat a specified area or an user defined object as
   a specific object.

   Navigation:

   Tools>virtual objects>virtual object manager>click new>click next>select class(ex
   button)>click next>click mark object>mark the area on AUT>click next>click
   next>enter collection name or project name>click finish>click close.




                            www.GCREDDY.COM                                                 47
For QTP Scripts & Other Information visit: www.gcreddy.com

     Note: when you run and click on virtual object you will see as virtual button.

                           Batch Testing or Batch execution


     Executing a group of tests at a time is known as batch execution. For performing batch
     execution QTP is providing a separate tool called test batch runner.

     Steps for Batch Testing:

     4. Prepare individual tests and run once.
     5. Open Test batch runner tool and form batches.
     6. Execute Test batches from Test batch runner.


     Forming a Test Batch:

Launch Test Batch Runner.

Navigation: Start>program>quicktest professional>Tools>Test Batch
Runner>File>new>batch>add>browse path of the test (like this add number of
tests)>save with MTB extension (Module test batche)>close test batch runner.

Running/Executing a Test Batch

Open Test Batch Runner Tool

Navigation: File>open>browse path of the test batch>batch>run

Note: Test batch runner launches QTP Tool, QTP runs Tests one by one.

Note: Allowing other products to run tests.
Navigation: Tools>Options>Run>check allow other mercury products>apply & Ok


Executing partial Test Batch

Open Test Batch runner >open Test Batch>Select or deselect tests>run test batch.


                   Dynamic Handling of Object Repositories


We can handle the object repositories through scripting with the help of a utility object

Repositoriescollection

Ex

RepPath1= "C:Documents and SettingsadminMy DocumentsLogin.tsr"
RepPath2= "C:Documents and SettingsadminMy DocumentsOrders.tsr"
Repositoriescollection.Add (RepPath1)



                             www.GCREDDY.COM                                                48
For QTP Scripts & Other Information visit: www.gcreddy.com

SystemUtil.Run "C:Program FilesHPQuickTest
Professionalsamplesflightappflight4a.exe"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "asdf"
Dialog("Login").WinEdit("Password:").Set "mercury"
Dialog("Login").WinButton("OK").Click
Pos=Repositoriescollection.Find(RepPath1)
Repositoriescollection.Remove(Pos)
Repositoriescollection.Add (RepPath2)
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("New").Click
Window("Flight Reservation").ActiveX("MaskEdBox").Type "101010"
Window("Flight Reservation").WinComboBox("Fly From:").Select "London"
Window("Flight Reservation").WinComboBox("Fly To:").Select "Denver"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").Activate
Window("Flight Reservation").Dialog("Flights Table").Activate
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "20289        LON
09:12 AM DEN 04:23 PM AA            $112.20"
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "gcr"
Window("Flight Reservation").WinButton("Insert Order").Click
Window("Flight Reservation").Close
Repositoriescollection.RemoveAll
Repositoriescollection.Add (RepPath1)
SystemUtil.Run "C:Program FilesHPQuickTest
Professionalsamplesflightappflight4a.exe"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "asdf"
Dialog("Login").WinEdit("Password:").Set "mercury"
Dialog("Login").WinButton("OK").Click


Note 1: For loading repository file (Reposotoirescollection.Add “path of the Repository
file”)

Or
Vairable =”path of the repository file”
Reposotoriescollection.add (variable)

Note 2: For finding repository position

Variable =reposotoirescollection.find (“Path of the repository file”)

Note 3: For removing a specific repository file.

Repositoriescollection.remove (position)

Note 4: For removing all loaded repositories

Repositoriescollection.removeall




                            www.GCREDDY.COM                                                49
For QTP Scripts & Other Information visit: www.gcreddy.com




                               Automation Framework


Framework: It is a generic work (outline work) or a set of guidelines designed by experts
to perform a task(s) in an effective, efficient and optimized way.

Automation framework: It is a systematic approach developed by experts for automating
any application.


Types of Framework:

   1.   Linear framework or Record/Playback framework.
   2.   Modular framework
   3.   Keyword driven framework
   4.   Hybrid framework


Linear framework:

            •   Generating the basic test using recording feature
            •   Enhancing the test using Tool features
            •   Debugging the test if required
            •   Running the test
            •   Analyzing results
            •   Sending defects


Modular framework:

        •   Generating the individual components for each and every task (Actions)
        •   Making them as reusable components
        •   Preparing the required driver scripts
        •   Executing the Drivers
        •   Analyzing the results.


Keyword driven framework:

        •   Creating the required   Test Case file & storing it in the corresponding folder.
        •   Creating the required   shared repository files & storing them in the
            corresponding folder.
        •   Creating the required   library files and storing them in the corresponding folder.
        •   Creating the required   environment variable files and storing them in the
            corresponding folder.




                             www.GCREDDY.COM                                                   50
For QTP Scripts & Other Information visit: www.gcreddy.com

Note: In this framework we create required tests and make them as functions, In driver
script we call required functions .

In this framework we have 2 scripts only.

   1. Initialization Script

   It launches QTP Tool and calls Driver Script
   2. Driver script
   It executes all tests one by one.


   If we want to execute our desired tests, then we need to modify the Driver script only.


                                        Recovery Scenarios


   During the execution QTP may face some problematic situations where in it needs to
   recover by itself and continue the execution.

   To do the same the Test Engineer would have defined a solution well in advance and
   made it available to current test before starting the execution.


   QTP may face 4 types of problematic situations:

   1.   Problems   related   to   path of the windows
   2.   problems   related   to   object state
   3.   Problems   related   to   Test execution
   4.   problems   related   to   application crash


   To define a solution for the above problems QTP has provided 4 trigger events.

   1.   Popup window
   2.   Object State
   3.   Test runner error
   4.   Application Crash



Creating a Recovery Scenario:

Navigation: Resources menu>Recovery Scenario manager>click new scenario icon>Click
Next>Select Trigger event(Test run error) >Click next>Select error type (item in list or
menu not found)>click next>click next>select recovery operation(Function Call)>click
next>browse path of function library(notepad)>click next >check another recovery
operation if required>click next>select post recovery operation(proceed to next
step)>click next>enter scenario name>click next>Check add scenario to current test if
required>click finish>click save>click close.


Editing a Recovery Scenario:


                                  www.GCREDDY.COM                                        51
For QTP Scripts & Other Information visit: www.gcreddy.com


Navigation: Resources menu>Recovery Scenario manager>click open>browse path of
scenario file>Select scenario>click edit icon>click next(through navigating modify
required values)>click finish>click save>click close.



                               Data Table Methods
Addsheet method


Adds the specified sheet to the run-time Data Table and returns the sheet

Syntax: Datatable.Addsheet “sheet name”

DeleteSheet method

Example1):

datatable.AddSheet "gcr"
datatable.ImportSheet "C:Documents and
SettingsAdministratorDesktopgcreddy.xls",1,3
n=datatable.GetSheet (3).GetRowCount
For i= 1 to n
Datatable.SetCurrentRow(i)
Invokeapplication "C:Program FilesHPQuickTest
Professionalsamplesflightappflight4a.exe"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set datatable("agent",3)
Dialog("Login").WinEdit("Password:").Set datatable("pwd",3)
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close
Next

   Example 2):

datatable.AddSheet "gcr"
datatable.ImportSheet "C:Documents and
SettingsAdministratorDesktopgcreddy.xls",1,3
n=datatable.GetSheet (3).GetRowCount
For i= 1 to n
       datatable.SetCurrentRow(i)

VbWindow("Form1").Activate
VbWindow("Form1").VbEdit("val1").Set datatable("V1",3)
VbWindow("Form1").VbEdit("val2").Set datatable("V2",3)
VbWindow("Form1").VbButton("ADD").Click
eres= Datatable.Value ("res",3)
ares=VbWindow("Form1").VbEdit("res").GetROProperty ("text")
If eres=ares Then
       datatable("res",3)=pass
       else
datatable("res",3)=fail



                           www.GCREDDY.COM                                           52
For QTP Scripts & Other Information visit: www.gcreddy.com

End If
Next




                    www.GCREDDY.COM                              53

More Related Content

What's hot

Complete testing@uma
Complete testing@umaComplete testing@uma
Complete testing@umaUma Sapireddy
 
API automation with JMeter + Bamboo CI
API automation with JMeter + Bamboo CIAPI automation with JMeter + Bamboo CI
API automation with JMeter + Bamboo CIMykola Kovsh
 
Model-based Testing: Taking BDD/ATDD to the Next Level
Model-based Testing: Taking BDD/ATDD to the Next LevelModel-based Testing: Taking BDD/ATDD to the Next Level
Model-based Testing: Taking BDD/ATDD to the Next LevelBob Binder
 
Manual Testing Material by Durgasoft
Manual Testing Material by DurgasoftManual Testing Material by Durgasoft
Manual Testing Material by DurgasoftDurga Prasad
 
Model Based Software Testing
Model Based Software TestingModel Based Software Testing
Model Based Software TestingEsin Karaman
 
Modern Testing Strategies for Evolving Ecosystems
Modern Testing Strategies for Evolving EcosystemsModern Testing Strategies for Evolving Ecosystems
Modern Testing Strategies for Evolving EcosystemsJulian Warszawski
 

What's hot (10)

Complete testing@uma
Complete testing@umaComplete testing@uma
Complete testing@uma
 
API automation with JMeter + Bamboo CI
API automation with JMeter + Bamboo CIAPI automation with JMeter + Bamboo CI
API automation with JMeter + Bamboo CI
 
Manual testing
Manual testingManual testing
Manual testing
 
Model-based Testing: Taking BDD/ATDD to the Next Level
Model-based Testing: Taking BDD/ATDD to the Next LevelModel-based Testing: Taking BDD/ATDD to the Next Level
Model-based Testing: Taking BDD/ATDD to the Next Level
 
Pimpri Chinchwad Software Testing Courses
Pimpri Chinchwad  Software Testing Courses  Pimpri Chinchwad  Software Testing Courses
Pimpri Chinchwad Software Testing Courses
 
Software testing
Software testingSoftware testing
Software testing
 
Testing ppt
Testing pptTesting ppt
Testing ppt
 
Manual Testing Material by Durgasoft
Manual Testing Material by DurgasoftManual Testing Material by Durgasoft
Manual Testing Material by Durgasoft
 
Model Based Software Testing
Model Based Software TestingModel Based Software Testing
Model Based Software Testing
 
Modern Testing Strategies for Evolving Ecosystems
Modern Testing Strategies for Evolving EcosystemsModern Testing Strategies for Evolving Ecosystems
Modern Testing Strategies for Evolving Ecosystems
 

Viewers also liked

Qtp commands
Qtp commandsQtp commands
Qtp commandsG.C Reddy
 
Qtp training in hyderabad
Qtp training in hyderabadQtp training in hyderabad
Qtp training in hyderabadG.C Reddy
 
Automation testing material by Durgasoft,hyderabad
Automation testing material by Durgasoft,hyderabadAutomation testing material by Durgasoft,hyderabad
Automation testing material by Durgasoft,hyderabadDurga Prasad
 
Manual Testing
Manual TestingManual Testing
Manual TestingG.C Reddy
 

Viewers also liked (7)

Qtp commands
Qtp commandsQtp commands
Qtp commands
 
Qtp training in hyderabad
Qtp training in hyderabadQtp training in hyderabad
Qtp training in hyderabad
 
Qtp test
Qtp testQtp test
Qtp test
 
Functions
FunctionsFunctions
Functions
 
Selenium Handbook
Selenium HandbookSelenium Handbook
Selenium Handbook
 
Automation testing material by Durgasoft,hyderabad
Automation testing material by Durgasoft,hyderabadAutomation testing material by Durgasoft,hyderabad
Automation testing material by Durgasoft,hyderabad
 
Manual Testing
Manual TestingManual Testing
Manual Testing
 

Similar to QTP 10 00 Guide

Pro smartbooksquestions
Pro smartbooksquestionsPro smartbooksquestions
Pro smartbooksquestionsyoummr
 
Qtp Training Deepti 1 Of 4187
Qtp Training Deepti 1 Of 4187Qtp Training Deepti 1 Of 4187
Qtp Training Deepti 1 Of 4187Azhar Satti
 
Interview qutions
Interview qutionsInterview qutions
Interview qutionssatyaragha
 
Qtp material for beginners
Qtp material for beginnersQtp material for beginners
Qtp material for beginnersRamu Palanki
 
QTP Interview Questions and answers
QTP Interview Questions and answersQTP Interview Questions and answers
QTP Interview Questions and answersRita Singh
 
Diff between win runner vs and qtp
Diff between win runner vs and qtpDiff between win runner vs and qtp
Diff between win runner vs and qtpRamu Palanki
 
UFT-1.pptx
UFT-1.pptxUFT-1.pptx
UFT-1.pptxAmarDeo7
 
HP Quick Test Professional
HP Quick Test ProfessionalHP Quick Test Professional
HP Quick Test ProfessionalVitaliy Ganzha
 
Qtp questions and answers
Qtp questions and answersQtp questions and answers
Qtp questions and answersRamu Palanki
 
What are the features in qtp
What are the features in qtpWhat are the features in qtp
What are the features in qtpRamu Palanki
 
QTP with Descriptive programming
QTP with Descriptive programmingQTP with Descriptive programming
QTP with Descriptive programmingKuldeep Sharma
 
Qtp with descriptive programming
Qtp with descriptive programmingQtp with descriptive programming
Qtp with descriptive programmingmedsherb
 
Qtp With Descriptive Programming
Qtp With Descriptive ProgrammingQtp With Descriptive Programming
Qtp With Descriptive ProgrammingKuldeep Sharma
 
Qtp 9.2 tutorials
Qtp 9.2 tutorialsQtp 9.2 tutorials
Qtp 9.2 tutorialsmedsherb
 

Similar to QTP 10 00 Guide (20)

Qtp
QtpQtp
Qtp
 
Qtp day 1
Qtp day 1Qtp day 1
Qtp day 1
 
Qtp basic
Qtp basicQtp basic
Qtp basic
 
Pro smartbooksquestions
Pro smartbooksquestionsPro smartbooksquestions
Pro smartbooksquestions
 
Qtp Training Deepti 1 Of 4187
Qtp Training Deepti 1 Of 4187Qtp Training Deepti 1 Of 4187
Qtp Training Deepti 1 Of 4187
 
Interview qutions
Interview qutionsInterview qutions
Interview qutions
 
Qtp material for beginners
Qtp material for beginnersQtp material for beginners
Qtp material for beginners
 
Qtp faqs
Qtp faqsQtp faqs
Qtp faqs
 
QTP Interview Questions and answers
QTP Interview Questions and answersQTP Interview Questions and answers
QTP Interview Questions and answers
 
Diff between win runner vs and qtp
Diff between win runner vs and qtpDiff between win runner vs and qtp
Diff between win runner vs and qtp
 
Qtp basics
Qtp basicsQtp basics
Qtp basics
 
UFT-1.pptx
UFT-1.pptxUFT-1.pptx
UFT-1.pptx
 
HP Quick Test Professional
HP Quick Test ProfessionalHP Quick Test Professional
HP Quick Test Professional
 
Qtp questions and answers
Qtp questions and answersQtp questions and answers
Qtp questions and answers
 
What are the features in qtp
What are the features in qtpWhat are the features in qtp
What are the features in qtp
 
QTP with Descriptive programming
QTP with Descriptive programmingQTP with Descriptive programming
QTP with Descriptive programming
 
Qtp with descriptive programming
Qtp with descriptive programmingQtp with descriptive programming
Qtp with descriptive programming
 
Qtp With Descriptive Programming
Qtp With Descriptive ProgrammingQtp With Descriptive Programming
Qtp With Descriptive Programming
 
QTP 9.2
QTP 9.2QTP 9.2
QTP 9.2
 
Qtp 9.2 tutorials
Qtp 9.2 tutorialsQtp 9.2 tutorials
Qtp 9.2 tutorials
 

More from G.C Reddy

New features in qtp11
New features in qtp11New features in qtp11
New features in qtp11G.C Reddy
 
QTP Training
QTP TrainingQTP Training
QTP TrainingG.C Reddy
 
Qtp (advanced)
Qtp (advanced)Qtp (advanced)
Qtp (advanced)G.C Reddy
 
Object Repository
Object RepositoryObject Repository
Object RepositoryG.C Reddy
 
Advanced Qtp
Advanced QtpAdvanced Qtp
Advanced QtpG.C Reddy
 
Advanced Qtp Book
Advanced Qtp BookAdvanced Qtp Book
Advanced Qtp BookG.C Reddy
 
File System Operations
File System OperationsFile System Operations
File System OperationsG.C Reddy
 
Web Dictionary
Web DictionaryWeb Dictionary
Web DictionaryG.C Reddy
 

More from G.C Reddy (13)

Html
HtmlHtml
Html
 
New features in qtp11
New features in qtp11New features in qtp11
New features in qtp11
 
QTP Training
QTP TrainingQTP Training
QTP Training
 
Qtp (advanced)
Qtp (advanced)Qtp (advanced)
Qtp (advanced)
 
Object Repository
Object RepositoryObject Repository
Object Repository
 
Advanced Qtp
Advanced QtpAdvanced Qtp
Advanced Qtp
 
Advanced Qtp Book
Advanced Qtp BookAdvanced Qtp Book
Advanced Qtp Book
 
Qtp Scripts
Qtp ScriptsQtp Scripts
Qtp Scripts
 
File System Operations
File System OperationsFile System Operations
File System Operations
 
Qtp Faq
Qtp FaqQtp Faq
Qtp Faq
 
Qtp Summary
Qtp SummaryQtp Summary
Qtp Summary
 
Qtp Scripts
Qtp ScriptsQtp Scripts
Qtp Scripts
 
Web Dictionary
Web DictionaryWeb Dictionary
Web Dictionary
 

Recently uploaded

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 

Recently uploaded (20)

Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 

QTP 10 00 Guide

  • 1. For QTP Scripts & Other Information visit: www.gcreddy.com QuickTest Professional QuickTest Professional 10.00 Product ID: QTPRPID 10.00/0 Version: 10.00.0.0 Build: 513 By www.gcreddy.com www.GCREDDY.COM 1
  • 2. For QTP Scripts & Other Information visit: www.gcreddy.com Index I. Basic Features of QTP II. Key Elements of QTP III. QTP Testing Process IV. Generating Tests V. Enhancing Tests VI. Debugging & Running Tests VII. Actions VIII. Functions IX. Regular Expressions X. Environment Variables XI. www.GCREDDY.COM 2
  • 3. For QTP Scripts & Other Information visit: www.gcreddy.com I) Basic features of QTP o QTP Launched in 2002 (Nov). By Mercury Interactive. Later taken over by HP, in 2007. o QTP is an Object Based Testing Tool. o QTP is for functional and Regression Testing. o It follows Keyword driven approach. o It supports Windows Operating Environment only. o It supports GUI based (Graphical user interface) and Web based Applications Automation, does not support CUI (Command user interface) Applications. o It has multilingual support. (It supports English, Chinese, Japanese, Korean, etc languages with respect to license.) o It has adapted Microsoft Visual Basic Scripting edition for programming and excel like spread sheet for Data driven testing. o SQL (Structured query language) embedded or inserted with QTP, so we can use SQL statements directly from QTP. o It can be integrated with other Tools like WinRunner and Quality Center. o It can be used for user interface (UI) test case automation and some limited (Non UI) Test case automation like File system operations and Data base operations. o It was derived from Astra QuickTest (mother tool of QTP). o It supports IE (Internet Explorer) only for recording tests, for execution it supports other browsers like Mozilla and AOL, opera Etc apart from IE. o QTP is a Desktop Application (I-Tier/Stand alone). o QTP has two types of License, 1. Seat or Node locked License, 2. Concurrent or float license. Seat license for one system and Concurrent License, we can use for any system but one user at any time. If we want multiple concurrent licenses we can purchase. o QTP has UNI code support. www.GCREDDY.COM 3
  • 4. For QTP Scripts & Other Information visit: www.gcreddy.com Version History of QTP • Astra Quick test (Mother tool of QTP) 1.0 to 5.0 • Quick Test Professional • 5.6 – Nov 2002 • 6.5 – 2003 • 8.0 – 2004 • 8.2, 8.3 –2005 • 9.0,9.1-2006 • 9.2- 2007 mercury interactive • 9.5 –2008 H.P • 10.00 –2009 January Add-In Manager QTP supports almost all industry leading technologies, but by default it does not support, with respect to add in license it supports. Default Add- ins of QTP are: • Activex • Visual basic • Web. Other available Add Ins are: .Dot NET, Java, People soft, Siebel, TE (Terminal Emulators), SAP for GUI, Sap for Web, Oracle Apps, Web Services etc. During QTP launching it shows Add in manger dialog box, Add in Manger lists out all available Add Ins in the company. User needs to select appropriate Add Ins for his application or AUT. One can select more than one Add Ins also; if we select unnecessary Add Ins QTP performance will be reduced. www.GCREDDY.COM 4
  • 5. For QTP Scripts & Other Information visit: www.gcreddy.com Launching QTP We can launch QTP BY selecting desktop icon otherwise start > programs> QTP Professional > QTP. During launching it shows Add-In Manager. Add-in manager window Select appropriate Add Ins and click okay. Quick Test Launches www.GCREDDY.COM 5
  • 6. For QTP Scripts & Other Information visit: www.gcreddy.com II) Key Elements of QTP Tool Window www.GCREDDY.COM 6
  • 7. For QTP Scripts & Other Information visit: www.gcreddy.com QTP Tool Window 1) Test Pane: It is programming interface of QTP, used for creating, editing, viewing and deleting test scripts. Test: It is a set of statements or set of one or more actions. (It is a local concept) Action: It is a set of Statements. (It is a local concept) Statement: A minimal executable unit. Statements may have keywords. (Keyword such as function, method, statement etc). It is a global concept. Test pane has 2 views. Expert view- Test in VB script format. www.GCREDDY.COM 7
  • 8. For QTP Scripts & Other Information visit: www.gcreddy.com QTP Test Pane-Expert View Key word view- Test in Icon based GUI format. QTP Test Pane-Keyword View Note1: Here in test pane Test is same but views are different, if you perform any modifications in one view those automatically reflects in another view. Note 2: Technical users use expert view and business user use key word view. Note 3: User can customize Test pane view options. Navigation: Tools Menu> view options> we can use font size and colors etc. 2) Active Screen www.GCREDDY.COM 8
  • 9. For QTP Scripts & Other Information visit: www.gcreddy.com It has an optional element of QTP, it takes snap shots of every statement that user performed action or operation on AUT. It can be used for understanding and editing the test easily. Navigation: View menu>active screen (for launching and closing) Configuring active screen: view>options>active screen tab>increase /Decrease capture level, apply and okay. Note 1: Generally novice testers use this feature but it occupies lot of memory space on QTP. www.GCREDDY.COM 9
  • 10. For QTP Scripts & Other Information visit: www.gcreddy.com Active Screen 3) Data Table It has an integrated spread sheet (Excel like), used for Data driven testing. Navigation: View menu>Data table (for launching and closing) Data driven Testing: Testing the same task(S) or same operation with multiple sets of test data. It can be used in two ways. www.GCREDDY.COM 10
  • 11. For QTP Scripts & Other Information visit: www.gcreddy.com 1. Enter test data directly into Data Table and use. 2. Importing data from external files (Flat files, excel sheets, etc) and Data bases (MS access, Sql Server, oracle, etc.) It has two types of sheets. 1. Global Sheet- for entire test /used for all actions in the test. 2. Action Sheets- for specific action only. Data table available in 2 ways: 1. Design time data table. (Attached with every test) 2. Run time data table. (Available in result window) Run time is a carbon copy of design time data table. QTP has Data table methods for performing operations on data table. www.GCREDDY.COM 11
  • 12. For QTP Scripts & Other Information visit: www.gcreddy.com QTP Tool window- Data Table 4) Debug Viewer It is used for locating and rectifying or fixing errors. It can be used for debugging the tests by step-by-step execution. We use step into, step over and step out commands for debugging. (debug commands) www.GCREDDY.COM 12
  • 13. For QTP Scripts & Other Information visit: www.gcreddy.com Through Debug viewer user can watch variables and change values of variables temporarily. Navigation: View menu>debug viewer (for launching and closing) QTP Tool Window-Debug Viewer 5) Missing Resources It can be used for showing missing resources those attached to current test such as (recovery scenarios, library files etc). www.GCREDDY.COM 13
  • 14. For QTP Scripts & Other Information visit: www.gcreddy.com Navigation: View menu >missing resources (for launching and closing) 6) Information This pane shows syntax errors automatically during saving the test. Navigation: view menu> information QTP Tool Window-Information Pane 7) QTP Commands QTP Commands are available in 3 ways. www.GCREDDY.COM 14
  • 15. For QTP Scripts & Other Information visit: www.gcreddy.com 1. Menu options 2. Tool Bar options 3. Short cut keys (for Some important operations only) File menu: Through file menu user can create, save tests, open existing tests, export tests in zip format. Edit Menu: It provides editing options and renaming, deleting and splitting actions. View menu: Through this menu we can launch and close, active screen, Data Table, Debug viewer, information, missing resources etc. Insert Menu: Through this menu user can inserting check points, out put values, synchronizing points. In this menu step generator available, using this user can generate recordable and non- recordable scripts. Through insert menu user can insert VB Script conditional and loop statements and transaction points (Start and End). www.GCREDDY.COM 15
  • 16. For QTP Scripts & Other Information visit: www.gcreddy.com Through insert menu user can create new actions, call existing actions and copy existing actions. Automation Menu: This menu provides Record, Run options and Run setting options Through this menu we can start normal recording, analog recording and Low level recording. Through this menu we can stop recoding, running and also we run tests. Resources Menu: This menu provides object repository and recovery scenarios options. Through this menu we can create /modify/delete objects information and we can associate repositories. Through this menu we can create, modify and delete recovery scenarios. Debug Menu: This menu provides debug commands for step by step execution. Through this menu we can insert/remove/break points. Tools Menu: This menu provides Tools settings option, view options and object identification configuration. Through this menu we can set tool options as well as test pane view options. In this menu object spy option available, through this we can get object’s information. (Properties and values) In this menu Virtual object option available; through this option we can create virtual objects. Window Menu: This menu provides QTP tool window style settings. Help Menu: This menu provides QTP help as well as VB Script help. Through this menu we can contact technical support people and we can send feedback. Through this menu we can check for updates and download or install directly. www.GCREDDY.COM 16
  • 17. For QTP Scripts & Other Information visit: www.gcreddy.com III) QTP Testing Process Planning o Analyzing the AUT o Automation Test Plan Generation o Automation Framework Implementation o Generating/Selecting Test cases for Automation o Collecting Test Data o QTP Tool Settings Configuration Generating Tests o Recording o Keyword driven methodology o Descriptive Programming Enhancing Tests o Inserting Checkpoints o Inserting Output values o Adding Comments o Synchronization o Parameterization o Inserting Flow Control Statements o Calling User defined functions o Generating Steps though Step Generator o Inserting Transaction Points o Regular Expressions Debugging Tests o Debug Commands & Break Points o Step by step execution o Watching Variables o Changing values of variables Running Tests o Normal Execution o Batch Execution o AOM Scripting www.GCREDDY.COM 17
  • 18. For QTP Scripts & Other Information visit: www.gcreddy.com o Tests Running through framework o Scheduled Execution Analyzing Results o QTP Result window o Defining our own Results o Exporting Results o Deleting Results Reporting Defects o Manual Defect Reporting o Tool based Defect Reporting o Working with Quality Center Analyzing the AUT Before we begin creating a test, we need to analyze our application and determine our testing needs. First, determine the development environments in which our application controls were developed, such as Web, Java, or .NET, so that we can load the required QuickTest add- ins. Then determine the functionality that we want to test. To do this, consider the various activities that customers perform in our application to accomplish specific tasks. Which objects and operations are relevant for the set of business processes that need to be tested? Which operations require customized keywords to provide additional functionality? While we are thinking about the business processes we want to test, consider how we can divide these processes into smaller units, which will be represented by our test's actions. Each action should emulate an activity that a customer might perform when using your application. As we plan, try to keep the amount of steps we plan to include in each action to a minimum. Creating small, modular actions helps make our tests easier to read, follow, and maintain. www.GCREDDY.COM 18
  • 19. For QTP Scripts & Other Information visit: www.gcreddy.com Recording and Running: In QTP there are 3 recording modes available for preparing Tests. 1. Normal Recording It records User Mouse and Keyboard operations on AUT with respect to objects, but unable to record continuous mouse operations like Digital Signatures, graphs, paints etc. During recording QTP generates VbScript statements in Test Pane, Simultaneously it stores objects information into object repository. Navigation: Automation>Record Or Select Record option on automation toolbar Or Use short cut key (F3) Steps for preparing a Test (through Recording): 1. Put AUT in base state 2. Select Record Option 3. It shows Record and Run Settings, Select type of Environment (Windows or Web) 4. Select Record Option (It shows two Options : 1. Record and Run Test on any open window based applications 2. Record and Run only on If we select first option it records on any opened application on Desktop. If we select Second option, it asks for the path of the AUT, After Providing the path it records only on that particular application.) 5. Click OK 6. Perform actions on AUT 7. Stop recording. 8. Save the Test 2. Analog Recording: It records the exact mouse and keyboard operations. We can use this mode for recording continuous mouse operations. It is not useful for recording normal operations why because it does not generate steps for each operation, generates total user actions in a Track File. The Track file is not editable. Navigation: 1. Keep tool under recording mode 2. Automation >Analog Recording OR www.GCREDDY.COM 19
  • 20. For QTP Scripts & Other Information visit: www.gcreddy.com Use Short cut Key (Shift + ALT+F3) Steps for preparing a TEST (through Analog Recording): 1. Launch AUT (or we can launch AUT through QTP) 2. Select Record option 3. Automation>Analog Recording 4. Analog Recording Settings Dialog box opens (In this Dialog box two options available. 1. Record relative to the screen 2. Record relative to the following window If we select first option QTP records User operations with respect to Desktop co- ordinates. If we select Second option, we have to show the window (AUT), after showing the Window it records with respect to that window co-ordinates.) 5. Select any one option in the dialog box and click Start Analog record. 6. It records User actions 7. Stop Recording 3. Low Level Recording It records some operations on Non-supported environments apart from Normal operations. This mode records at the object level and records all run time objects as window or winobject Test objects. Use Low Level Recording for recording in an environment not recognized by QTP. Navigation: 1. Keep tool under recording mode 2. Automation >Low Level Recording Steps for preparing a TEST (through Low Level Recording): 1) Launch AUT (or we can launch AUT through QTP) 2) Select Record option 3) Automation> Low Level Recording 4) Perform options on AUT 5) Stop Recording 6) Save the Test www.GCREDDY.COM 20
  • 21. For QTP Scripts & Other Information visit: www.gcreddy.com Object Repository Object Repository: It is a storage place of QTP where we can store the objects information and it also acts as interface between the test script and the AUT in order to identify the objects during execution. Object: Object is something, which has structure and properties. Software objects: We call windows, WebPages, buttons, edit boxes, check boxes etc.. as software objects. Types of Object in QTP: There are four types of object available in QTP. 1. Run time objects 2. Test objects 3. Utility objects 4. Automation objects/User defined objects. Run time objects: The objects present in the AUT. Ex: Buttons, links, etc… Test Objects: References of Run time objects. Ex: WinEdit, WinButton, WebButton, Link, etc… Note: Test objects names vary from one environment to another. Ex: Run time objects Test objects in Test objects in VB Test objects in web windows Environment Environment Environment buttons WinButton VBButton WebButton Edit box WinEdit VBEdit WebEdit Check box Wincheckbox Vbcheckbox Webcheckbox Utility objects They are QTP reserved objects used for testing and result reporting. Ex: 1. SystemUtil for launching/closing the application. 2. Reporter for defining results. www.GCREDDY.COM 21
  • 22. For QTP Scripts & Other Information visit: www.gcreddy.com 3. Services for inserting transaction points 4. Environment for using environment variables Automation objects/User defined objects User can create objects; those can be used for performing specific operations. Ex: Creating objects in file system object class, adodb.connection class, dictionary object class, excel. Application class etc. There are two types of repository available in QTP. 1. Local repository (.MTR extension) 2. Shared repository(.TSR extension) Local Repository: QTP creates a Local Repository for every action automatically during Recording. That cannot be shared among tests. User can add some more objects to Local repository User can perform rename, delete operations in local repository. As it is QTP internal file user no need to save modifications. Navigation: Resource menu>object repository (Short cut key Ctrl+R) www.GCREDDY.COM 22
  • 23. For QTP Scripts & Other Information visit: www.gcreddy.com QTP- Local Repository Shared Repository: User (Test Engineer) creates shared repository by adding objects. That can be shared among number of tests. Using this method user can perform modifications on objects easily. Operations on Object Repository Adding objects a. Local Repository: Navigation: open local repository (resource menu>object repository) >objects>Add objects to Local>show the object>click ok (No need to save separately, it saves automatically) B. Shared Repository: Navigation: Resource menu>object repository manager>object>Add objects>show the window/object>click ok www.GCREDDY.COM 23
  • 24. For QTP Scripts & Other Information visit: www.gcreddy.com o Selected object only o Default object types o All objects types o Selected object types (If we select first option it stores Selected objects only, if we select second option it stores all default objects, if we select third option it stores All objects including static objects, if we select fourth option, we have to select object classes then it stores that class objects, we can select more than one class also.) Renaming objects a. Local Repository: Resources > object repository >select object and right click >choose rename option >modify the name>release the mouse.>close repository b. Shared Repository: Resources >object repository manager>file>open>browse path of the repository file >file>enable editing>select object &Right click>choose rename option>modify the name > release mouse>save the file & close repository manager. Deleting objects a. Local Repository: Resources > object repository >select object and right click >choose delete option >confirm deletion>. >close repository b. Shared Repository: Resources >object repository manager>file>open>browse path of the repository file >file>enable editing>select object &Right click>choose delete option>confirm the deletion >save the file & close repository manager. Associating objects repositories to an action Resources>Associate repositories>click add icon (+)>browse path of the repository>Associate with an action>click ok Merging Repositories Resources > object repository manager>tools>object repository merge tool >browse path of the first repository> browse path of the second repository>click ok>click close>save the merged repository>close the repository manager. Note: After merging also, source repository files will be available, if we do not want source files we can delete. www.GCREDDY.COM 24
  • 25. For QTP Scripts & Other Information visit: www.gcreddy.com Defining new test objects Navigation: Object>Define new test object >Select Environment>Select Class of the object>Enter name of the object>Click Add>click close>Select object >select property name>enter value (like this select one by one properties and enter values)>save Note: This feature can be used for preparing tests before the AUT is ready. Spying objects For getting objects information, (Test objects names, property & Values) QTP is providing a feature called Object Spy, using this we can get objects information. Navigation>Tools>object spy>take hand icon & Show the object>get information (Object Spy shows the specific objects all available properties with their values) Note: As Object spy is an important feature, it can be available in 3 Areas.(1. In tools Menu 2. In local repository 3. In Repository manager) View Options Locate in Repository This feature can be used for identifying objects from application to repository. Navigation: View>Locate in repository >show the object>click Ok>it locates specified object in the repository. Highlight in Application This feature can be used for identifying objects from repository to application. Navigation: Select object in the repository >view>highlight in application>it highlights specified objects in the application. Exporting Repository to an XML file We can export our repository file to an xml file. Navigation: File >export Test objects to XML Enter the file name and Save with xml extension. Importing Repository from XML file. We can import XML file to our repository. Navigation: File>import from XML >browse path of the XML file >it loads objects. Note: The purpose of this feature is Editing objects information outside of the QTP www.GCREDDY.COM 25
  • 26. For QTP Scripts & Other Information visit: www.gcreddy.com Methods Activate: It activates dialog boxes/Windows Syntax: Object hierarchy. Activate Ex: Dialog(“Login”).Activate Window(“Flight Reservation”).Activate Click Method: It clicks on an object (Buttons) Syntax: Object hierarchy. Click Ex: Dialog(“Login”).Winbutton(“ok”).click Close Method: It closes the window,Dialog box, Browser window etc. Syntax: Object hierarchy. Close Ex: Window(“Flight Reservation”).Close Browser(“Browser”).Close DBL CLICK: It Double clicks the object. Set Method: It can be used in three ways. a. For setting the value of an edit box Syntax: Object Hierarchy. SET “Value” Ex: Dialog (“Login”).WinEdit(“Agent Name”).Set “asdf” b. Selecting a Radio Button Syntax: Object Hierarchy. Set Ex: Window("Flight Reservation").WinRadioButton("Business").Set c. Selecting/Deselecting check boxes Syntax:object Hierarchy.Set “ON/off” Ex: Window ("Flight Reservation"). Dialog("Open Order").WinCheckBox("Order No.").Set "ON" Select Method: It is used for selecting an item from a combo box or list box. Syntax: Object hierarchy.select “item” Ex: www.GCREDDY.COM 26
  • 27. For QTP Scripts & Other Information visit: www.gcreddy.com A. Window("Flight Reservation").WinComboBox("Fly From:").Select "London" B. Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "12572 GetVisibletext: It returns Text from the specified area. Syntax: Variable =object hierarchy.getvisibletext Ex: x=Window("Flight Reservation").WinComboBox("Fly From:").GetVisibleText msgbox x GetRoproperty: It returns current object property value. It can be used for getting any object’s, any property value. Syntax: Variable = object hierarchy.getroproperty (“property name”) Ex: x=Window("Flight Reservation").WinEdit("Tickets:").GetROProperty ("width") msgbox x Navigate Method: It opens a specified URL in the Browser. Syntax: object hierarchy.navigate “URL” Ex: Browser("Yahoo!").Navigate "http://www.google.co.in" Getitemscount: It returns number of items in a combobox. Syntax: Variable=object hierarchy.getitemscount Ex: x=Window("Flight Reservation").WinComboBox("Fly From:").GetItemsCount msgbox x Getcontent: It returns all items from a combobox. Syntax: variable=object hierarchy.GetContent Ex: x=Window("Flight Reservation").WinComboBox("Fly From:").GetContent msgbox x Exist property: It checks whether the object is available or not. Syntax: Object hierarchy.exist(time in seconds) Ex: Window("Flight Reservation").Exist(5) www.GCREDDY.COM 27
  • 28. For QTP Scripts & Other Information visit: www.gcreddy.com Descriptive Programming/Programming Descriptions Providing objects information directly into the test script is called Descriptive Programming. These scripts can be executed faster than repository based scripts. Descriptive programming is basically 2 types. 1. Static Programming 2. Dynamic Programming Static Programming: In this style of script generation, we provide objects information directly into the script. Ex: Invokeapplication "C:Program FilesHPQuickTest Professionalsamplesflightappflight4a.exe" dialog("text:=Login").Activate dialog("text:=Login").Winedit("attached text:=Agent Name:").Set "asdf" dialog("text:=Login").Winedit("attached text:=Password:").Set "mercury" dialog("text:=Login").Winbutton("text:=OK","width:=60").Click Note: 1. Dialog, WinEdit and WinButton – Test Objects 2. text, attached text - Property names 3. Login, Agent Name:, Password:, OK - Property values or Logical Names of the Object 4. Activate, Set, Setsecure, Click - Methods Note2: If we feel one property information is not sufficient for recognizing the object uniquely, then we can provide more properties information by separating with commas. Note 3: If we want to get objects information (Test objects, properties and values), we can use object spy feature. This feature is available in Tools Menu, in local repository and in repository manager. Dynamic Programming: In this style of script generation, first we create description objects, provide properties information and use description objects in the test script. Creating Properties Collection Objects Set oLogin=description.Create Set oAgent=description.Create Set oPassword=description.Create Set oOk=description.Create www.GCREDDY.COM 28
  • 29. For QTP Scripts & Other Information visit: www.gcreddy.com Entering Properties Information into Objects oLogin("text").value="Login" oLogin("width").value=320 oLogin("height").value=204 oAgent("attached text").value="Agent Name:" oPassword("attached text").value="Password:" oOk("text").value="OK" Generating Tests using Properties collection Objects Invokeapplication "C:Program FilesHPQuickTest Professionalsamplesflightappflight4a.exe" Dialog(oLogin).Activate Dialog(oLogin).Winedit(oAgent).Set "asdf" Dialog(oLogin).Winedit(oPassword).Set "mercury" Dialog(oLogin).Winbutton(oOK).Click Note1: Create Description objects and put into one library file, by associating that library file, we can generate tests. Note2: Dynamic programming is some difficult in preparation than static programming but maintenance is very easy. Enhancing Tests After generating the basic test, we have to enhance the test in order to Test the AUT with respect to requirements. There are several methods available in QTP for enhancing the TEST. 1. Inserting Check Points 2. Inserting Output Values 3. Adding Comments 4. Inserting Flow Control Statements 5. Synchronization 6. Parameterization 7. Generating Steps through Step Generator 8. Inserting Transaction Points:(Start and End) Inserting Check Points: Check point is a verification point, it takes expected result from the user and compares with actual results during execution and provides test results. There are 11 check points available in QTP: 1. Standard check point www.GCREDDY.COM 29
  • 30. For QTP Scripts & Other Information visit: www.gcreddy.com 2. Text check point 3. Text area check point 4. Bit map check point 5. Data base check point 6. Accessibility check point 7. XML Check point (from application) 8. XML Check point (from resource) 9. Page check point 10. Image checkpoint 11. Table checkpoint Note 1: From 6 to 11 checkpoints are only for Web. Note 2: From 9 to 11 checkpoints are hidden checkpoints, we can insert these checkpoints through standard checkpoint. 1. Standard Checkpoint: It checks object property values. We can use this checkpoint for checking any property value. Navigation1(Inserting standard checkpoint) : Keep tool under recording mode>place cursor in desired location>Insert arrow check point>Standard checkpoint>Show the object (which is result window)>click okay>select property and enter expected results&click ok and stop recording. Navigation 2 (editing standard checkpoint) Select checkpoint statement and right click >choose checkpoint properties option>modify the value>click ok. Navigation 3 (Deleting standard checkpoint) Select checkpoint statements and right click>choose delete option. Inserting Standard check points through active screen: View>Active Screen>place cursor in desired location>Place mouse pointer on active screen&right click>choose insert standard checkpoint option>click ok>enter expected result>click ok Note: Inserting Standard check points through keyword view same as in expert view. Note: We can insert standard checkpoints in 3 ways. 1. Through expert view, 2. Through keyword view, 3. Through Active screen. 2. Text Checkpoint: It checks object’s text property value in different ways. Navigation: keep tool under recording mode>Insert check point>text checkpoint>Show the object >click ok>Select options www.GCREDDY.COM 30
  • 31. For QTP Scripts & Other Information visit: www.gcreddy.com (Match case, ignore spaces, exact match, text not displayed.) We can select one or more options>click ok & stop recording. 3. Text Area Checkpoint: It checks the text area present in the application. Navigation: Keep tool under recording mode >Insert arrow checkpoint>Text area checkpoint>Mark the area of text >select one or more options (Match case, ignore spaces, exact match, text not displayed.) Click ok and stop recording. 4. Bitmap checkpoint: It compares bit maps, we can compare complete bit maps as well as part of the bit maps. Navigation: Keep tool under recording mode>insert >checkpoint>bitmap checkpoint>show the bitmap>click ok>select “check only selected area” option if we want to compare part of the bitmap>click ok>stop recording. 5. Database checkpoint: It checks Content of the back end database. Navigation: Insert>checkpoint>database checkpoint>choose “specify SQL statement manually”option>click next >click create>select machine data source>Select DSN(QT_flight32)>click ok>enter SQL statement (select * from orders)>finish>click ok. Note: here we do not need to put on recording mode and we do need AUT since data is from backend. 6. Accessibility check point: It checks whether the webpage in our web application is developed according to W3C (world wide web consortium) rules and regulations or not. It is a configurable checkpoint, according to our requirements, we can customize. Configuring accessibility checkpoint: Tools>options>web>adavanced>check/uncheck items >click apply>click ok Navigination: Keep tool under recording mode with web environment >insert>checkpoint>accessibility checkpoint>show the webpage>click ok>click ok>stop recording. Result Criteria: 1. If item is available but not according to W3C rules then fail. 1. If an item is available, according to W3C rules then Pass. 2. If an item is not available then result would be pass 7.XML Check point (from application) It checks content of the XML file. Navigation: Keep tool under recoring mode in web environment>insert >checkpoint (from application)>show the xml pages>click ok>stop recording. www.GCREDDY.COM 31
  • 32. For QTP Scripts & Other Information visit: www.gcreddy.com 9. XML Check point (from resource) It checks content of the XML file. Navigation: Insert>checkpoint>xml checkpoint (from resource)>browse path of the XML File >click ok>click ok. Note: 1. If XML file is an individual and path available, then we can go for inserting xml checkpoint from resource. Note: 2. If XML file is part of web application, separte path is not available then we can choose inserting XML checkpoints from application. 10. Page checkpoint: It checks number of links, images available in a web page. It is a hidden checkpoint, we can insert this through standard checkpoint. Navigation: Keep tool under recording mode with web environment >insert>checkpoint>Standard checkpoint>show the page>click ok>click ok>stop recording. 11. Image checkpoint: It checks Image property values. Navigation: keep recording mode with web environment >insert>checkpoint>standardcheckpoint>show the image>select image>click ok>click ok>stop recording. 12. Table checkpoint: It checks content of the web tables. Navigation: Keep tool under recording mode under web environment>insert>checkpoint>standard checkpoint>show the table>click ok >stop recording. Inserting Output Values: It is a step in which one or more values are captured during execution. The values can later be used as input at a different point in the run session or we can use as input for another test. It is stored in run time data table; it is located in QTP result window and can be retrieved later. Types of Output Values: 1. Standard output value 2. Text output value 3. Text area output value 4. Database output value 5. XML output value (From Application) 6. XML output value (From Resource) www.GCREDDY.COM 32
  • 33. For QTP Scripts & Other Information visit: www.gcreddy.com A. Standard output value: We can use standard output values to output the properties values of most objects. Navigation: Keep tool under recording mode >Insert >output value>standard output value>show the object>click ok>select property>modify the column name (if required)>click ok>click ok>stop recording. B. Text output value: We can use Text output values to output text strings displayed in an application. When creating a text output value we can output a part of the objects text and we can also specify text before and after options. Navigation: Keep tool under recording mode>Insert>output value>text output value>show the text>select one of the option(output text/text before/text after)>click modify if you want to change the column name>click ok>click ok.>check in runtime table after running it. C. Text Area output value: We can use text area output values to output text strings displayed within a defined area of the screen. Navigation: keep tool under recording mode>insert>outputvalue>text area output value>Mark the text area>click modify the column name if necessary>click ok>again click ok>check in run time table after running it.. D. Database output value: We can use Database output values to output the value of the contents of database cells. Navigation: Insert>outputvalue>Database output value>choose specify SQL statements manually>click next>click create>Select Machine Data source>Select Driver (QT_flight32)>click ok>enter SQL statement(select *from orders)>click finish>select datacells>click ok>Run and it will capture and see the results in run time table. E. XML output value(from application): we can use XML output values to output the values of XML elements in XML documents. Navigation: Keep tool under recording mode with web environment>Insert>output value>XML output value from application>Show the XML document>select elements>click ok>stop recording. F. XML output Value (From Resource) we can use XML output values to output the values of XML elements in XML documents. Navigation: Insert>output value>XML output value from resource>browse path of the XML file >click ok>select elements>click ok. Adding Comments: Purpose of Comments: o For making the script understandable o For making the Script Disable from execution www.GCREDDY.COM 33
  • 34. For QTP Scripts & Other Information visit: www.gcreddy.com Syntax: 1. Use Apostrophe (‘) before the statement 2. Use REM Command with single space before the statement Comment a Block of Statements: Navigation: Select block of statements >edit menu>advanced>comment block Or After selecting block of statements use shortcut key Ctrl+M Uncomment a block of statements: Navigation: Select comment block>Edit menu> Advanced>Uncomment block Or After selecting comment block, Use shortcut key ctrl+shift+M Inserting Flow Control Statements: QTP adapted Vbscript engine for applying programming logic to tests. We can insert Vbscript conditional statements and loop statements for applying the logic. In Vbscript there are 2 types of conditional statements and four types of loop statements available. Synchronization It is a process of matching the speeds of both QTP and AUT in order to get proper execution and results. Where Synchronization is required: During test execution QTP gives instructions one by one with same speed, but AUT takes less time for some operations execution and more time for some operations execution, that time we may not get proper execution and results. In order to get proper results in between QTP & AUT synchronization is required. There are several methods available in QTP for synchronization. 1. Inserting Wait statements. 2. Inserting Synchronization points. 3. Increasing Tool default synchronization time. 4. Sync Method (Only for WEB) Inserting Wait Statements: We can insert wait statements in our test in order to make QTP to wait until AUT completes current operation. Syntax: Wait(time in seconds) Note: If we insert wait statements QTP waits up to maximum time even though operation is completed. Inserting Synchronization point: www.GCREDDY.COM 34
  • 35. For QTP Scripts & Other Information visit: www.gcreddy.com Place cursor in desired location>keep tool under recording mode>Insert menu>Synchronization point >show the object >click ok>select property name & Value(True)>enter time in Milli seconds>click ok>Stop recording. Note: if we insert Synchronization points, it does not wait up to maximum time, after completion of the current operations, it goes to next step immediately. Syntax: object hierarchy.waitproperty “property name”,value,time in milli seconds. Increasing Tool default synchronization time: Navigation: File>settings>run tab>increase object synchronization time out>apply>ok Note: If we increase QTP tool default time that can be applied for all statements in the test, but QTP does not wait up to maximum time unnecessarily, After completion of one statement execution it goes to next statement immediately. Sync Method: (only for WEB) Waits for the browser to complete current navigation. Syntax: Object Hirearchy.Sync Ex: Browser("Yahoo! Toolbar").Page("Yahoo! Toolbar").Sync Selecting an appropriate Method: 1. Suppose in our test one or more statements only are taking more time for execution then selecting “Inserting synchronization method” is better. 2. Suppose in our test more statements are taking more time for execution then selecting “increasing tool time out” . 3. Above two are local features but wait statement is Vbscript feature, even though some drawbacks are there in using wait statement, it is better to use wait statement in functions. Inserting Transaction Points:(Start and End) We can insert Transaction points for measuring Transaction time. It is a performance concept but QTP supports measuring transaction time per user only. Syntax: Services.StartTransaction "name of transaction" ------- statements --------- -------- services.EndTransaction "name of the transaction" Note: We can insert multiple transactions points in a test. www.GCREDDY.COM 35
  • 36. For QTP Scripts & Other Information visit: www.gcreddy.com Parameterization Passing parameters, through this concept we can pass multiple values. We use parameterization in Data Driven Testing. Data Driven Testing: Testing the Same operation with multiple sets of test data. Types of Parameterization: We can parameterize tests in several ways. 1. Through Loop Statements 2. Dynamic Test Data Submission 3. Through Data Table 4. Fetching Test Data directly from External files (Flat files & Spreadsheets) 5. Fetching Test Data directly from Databases (MSAcess, oracle etc). 6. Getting Test Data from front end objects. 1. Through Loop Statements: We can use loop statements for passing sequential numbers & Logical Numbers. Note: We can’t generate Strings. For orderno=1 to 10 step 1 ' for one increment step keyword is not mandatory Window("Flight Reservation").Activate 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 orderno Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click Next 2.Dynamic Test Data Submission: Through Loop Statements we can give strings also but every time user has to enter data. For x=1 to 3 Agent =inputbox("enter an Agent Name") Password=inputbox("enter a password") invokeapplication "C:Program FilesMercury InteractiveQuickTest Professionalsamplesflightappflight4a.exe" Dialog("Login").Activate Dialog("Login").WinEdit("Agent Name:").Set Agent Dialog("Login").WinEdit("Agent Name:").Type micTab Dialog("Login").WinEdit("Password:").SetSecure password Dialog("Login").WinButton("OK").Click Window("Flight Reservation").Close Next 3. Through Data Table: QTP adds one data table (Spreadsheet) for every test, we can use Data Table for Data Driven Testing. www.GCREDDY.COM 36
  • 37. For QTP Scripts & Other Information visit: www.gcreddy.com It has 3 types of usage . a. Entering test data directly into data table and use b. Importing test data from external Flat files c. Importing test data from external Spread sheets d. Importing test data from Data bases. A. Entering test data directly into data table and use. Steps: Generate the basic test>open data table(View>Data Table) Click on column header>enter the name of the field (like this we can create number of columns) > Enter Data>connect the data to test (variable=datatable(“column name”, Sheet id) Example: agent=datatable(“agent”,1) Pass parameters.) Run the test. Agent = Datatable("Agent",1) pwd=Datatable ("Password",1) invokeapplication "C:Program FilesMercury InteractiveQuickTest Professionalsamplesflightappflight4a.exe" Dialog("Login").Activate Dialog("Login").WinEdit("Agent Name:").Set Agent Dialog("Login").WinEdit("Agent Name:").Type micTab Dialog("Login").WinEdit("Password:").SetSecure pwd Dialog("Login").WinButton("OK").Click Window("Flight Reservation").Close b. Importing test data from external files: Open Data Table (view>Data table)>place mouse pointer on data table and right click>file>import from file>Click ok>Browsw path of the file(it imports data from the flat file) Connecting Test Data to QTP Test as above and run the test. c. Importing test data from external Spread sheets: Open Data Table (view>Data table)>place mouse pointer on data table and right click>file>import from file>Click ok>Browse path of the excel sheet (it imports data from the excel sheet) Connecting Test Data to QTP Test as above and run the test. D. Importing test data from Data bases: Through Data table we can import Test Data from Data bases, but first we have to create /get the DSN(Data source Name)& we have to use SQL Commands. www.GCREDDY.COM 37
  • 38. For QTP Scripts & Other Information visit: www.gcreddy.com 1. Creating a Test Database: open MS Access (or we can use any other database). Start programs>MS Office>MS Access>file >new>Select blank Database>enter name of the database>Save with mdb extension. Creating Tables: Select Create table in design view>Enter field name(Agent)and Select data type(text) Like this we can create number of fields>save&enter table name. Entering Data into Tables: Select table>enter the data. Creating DSN & importing data Navigation: view>data table>Place mouse pointer on Data table>sheet>import>from database(Database query wizard opens)>choose ‘specify SQL statements manually>click next >click create>click new>select driver type>click next >browse path to store> enter DSN Name>Click Save>click next>click finish>select>browse the database& select>click ok>click ok>select DSN>click ok>enter SQL statement (select *from login)>click finish. Note: DSN Creation is one time activity, by using the DSN we can get data for number of tests. 4. Fetching Test Data directly from Flat files Dim fso, myfile Set fso=createobject("scripting.filesystemobject") Set myfile=fso.opentextfile("d:trigun.txt",1) myfile.skipline While myfile.atendofline <> true x=myfile.readline S=split(x,"@") SystemUtil.Run "C:Program FilesMercury InteractiveQuickTest Professionalsamplesflightappflight4a.exe","","C:Program FilesMercury InteractiveQuickTest Professionalsamplesflightapp","open" Dialog("Login").Activate Dialog("Login").WinEdit("Agent Name:").Set s(0) Dialog("Login").WinEdit("Agent Name:").Type micTab Dialog("Login").WinEdit("Password:").SetSecure S(1) Dialog("Login").WinEdit("Password:").Type micReturn Window("Flight Reservation").Close Wend Fetching Test Data directly from Excel Sheets Fetching Test Data directly from Databases option explicit Dim con,rs Set con=createobject("adodb.connection") www.GCREDDY.COM 38
  • 39. For QTP Scripts & Other Information visit: www.gcreddy.com Set rs=createobject("adodb.recordset") con.provider=("microsoft.jet.oledb.4.0") con.open "C:Documents and SettingspoojaMy Documentstrigun.mdb" rs.open "select * from login",con do until rs.eof=true SystemUtil.Run "C:Program FilesMercury InteractiveQuickTest Professionalsamplesflightappflight4a.exe","","C:Program FilesMercury InteractiveQuickTest Professionalsamplesflightapp","open" Dialog("Login").Activate Dialog("Login").WinEdit("Agent Name:").Set rs.fields ("agent") Dialog("Login").WinEdit("Agent Name:").Type micTab Dialog("Login").WinEdit("Password:").SetSecure rs.fields("password") Dialog("Login").WinEdit("Password:").Type micReturn Window("Flight Reservation").Close rs.movenext loop Debugging the TEST Debugging is a process of executing the script or a program in a User designed fashion with some temporary break points in order to identify the errors. For debugging, QTP is providing debug commands and breakpoints. Debug Commands: 1. Step Into: (short cut key F11) a. It starts execution b. It executes one statement at a time. c. If it is function call, it opens the function, after that it executes one statement at a time. 2. Step Over (Short cut key F10) e. It executes one statement at a time after execution starts f. It executes all functions statements at a time Note: After opening the function, if we use step over it executes one statement at a time only. 3. Step Out (shift +F11) It executes all remaining statements in a function at a time. Ex: Dim a,b,c a=100 b=200 c=a+b msgbox c msgbox "hello" www.GCREDDY.COM 39
  • 40. For QTP Scripts & Other Information visit: www.gcreddy.com Call hyderabad msgbox "bye bye" Note: Create a script and work on it Break Point: This feature is used for breaking the execution temporarily. Navigation: Place cursor in desired location >Debug menu>Insert/Remove break point Or Use short cut key (F9) Or Place mouse pointer before the statement and click. Note: If we want to execute Some part of the Test Script at a time and some other part of the test script step by step, there we can use breakpoints. Debug viewer Pane: It is used for viewing, modifying or setting the value of the variables during the execution break with the help of 3 Tabs. 1. Watch 2. Variables 3. Command Note: Through Debug Viewer Pane, We can watch variables whether the variables are taking correct values or not at a specific point of time. We can change Values of Variables temporarily. Ex : Dim x,y,z x=10 y=20 z=x+y msgbox z msgbox "Hello" x=35 y=67 z=x*y msgbox z msgbox "bye bye" Navigation: debug viewer>Use step into feature. www.GCREDDY.COM 40
  • 41. For QTP Scripts & Other Information visit: www.gcreddy.com Running the Test / Executing the Test 1. Normal execution/ General execution (Executing one test at a time) 2. Batch execution/Batch Testing Executing a group of tests at a time is known as batch execution. For performing batch execution QTP is providing a separate tool called test batch runner. Steps for batch testing: 1. Prepare individual tests and run once. 2. Open Test batch runner tool and form batches. 3. Execute Test batches from Test batch runner. Forming a Test Batch: Launch Test batch runner. Navigation: Start>program>quicktest professional>Tools>Test Batch Runner>File>new>batch>add>browse path of the test (like this add number of tests)>save with MTB extension (Module test batche)>close test batch runner. Executing a TEST Batch. Open Test Batch Runner Tool Navigation: File>open>browse path of the test batch>batch>run Note: Test batch runner launches QTP Tool, QTP runs Tests one by one. Note: Allowing other products to run tests. Navigation: Tools>Options>Run>check allow other mercury products>apply & Ok Executing partial Test Batch Open Test Batch runner >open Test Batch>Select or deselect tests>run test batch. Note: QTP does not provide Batch wise test results. We have to view Test wise results through Test Result viewer. 3. AOM Scripting (Automation Object Model) We can use QTP automation object Model to write scripts that automate our QTP operations. QTP automation object model provides objects, methods and properties that enable us to control QTP from another application. We can use Scripting languages or programming languages such as VBscript, Java script or VC++, .Net for automating QTP operations. www.GCREDDY.COM 41
  • 42. For QTP Scripts & Other Information visit: www.gcreddy.com Ex: option explicit Dim qtApp,qtTest Set qtApp=createobject ("quicktest.application") qtApp.Launch qtApp.visible=True qtApp.open "C:Documents and SettingsadminMy Documentslogin" Set qtTest=qtApp.Test qtTest.run qtTest.close qtApp.open "C:Documents and SettingsadminMy Documentsopen order" Set qtTest=qtApp.Test qtTest.run qtTest.close qtApp.quit Notes: Set is for statement, QtApp is variable, Createobject is for function, “quicktest.application” is used for class value Launch is used for method. 4. Executing Tests through Framework 5. Scheduled execution Navigation: Start>Settings >control panel>Select on scheduled tasks>Click add scheduled task>click next>Select Application as quick test professional>Click next>Type name of the task AOM.Vbs>select the schedule>click next>enter time and date>click next>enter system name and password if required>click next>click Finish. 6. Analyzing the results: a. Test result viewer: QTP is providing Test Result Viewer for viewing and exporting test results. Navigation: Start>Programs>Quick Test Professional>Test Result Viewer>File >open>Browse path of the test>Select Result>click open. Or From QTP Tool window: Automation menu>results>browse path of the test> Select Result>click open. Or Click result icon on Automation tool bar> B. Deleting Test Results: For Deleting test results QTP is providing a separate Tool called Test Result Deletion Tool. Navigation: Start programs>quick test professional>Tools>Test result Deletion tool>browse path of the test>Select result>click Delete>click close. C. Result Reporting : From QTP result window. www.GCREDDY.COM 42
  • 43. For QTP Scripts & Other Information visit: www.gcreddy.com Navigation: File >export to HTML file>click export>browse path of the location>save. Note: In QTP 10.0 , Apart from HTML format DOC, XML & PDF formats also available. Reporting Defects Functional Automation Defect Management Tasks QTP Manual After analyzing the results, open company prescribed defect report template, enter defect details and send QTP Any Tool like BugZilla or After analyzing the results, issue –Tracker or PR – open the TOOL, open the Tracker, etc. defect reporting template, enter defect results and send QTP QC (Quality Center) In between QTP & QC back to back integration. We can send defects directly from QTP result window. Other QTP Features Actions We divide our test into actions to streamline the process of testing. Purpose of Actions: For understandability For reusing components Types of Actions: Non Re usable actions Re usable actions External actions Operations on actions: • Creating Actions • Splitting Actions • Renaming Actions www.GCREDDY.COM 43
  • 44. For QTP Scripts & Other Information visit: www.gcreddy.com • Deleting Actions • Calling an Action • Copying an Action • Making an Action Reusable/Non Reusable Creating an action: Insert>call to new action>enter name of the action>click ok Steps: 1. Create required actions(ex login, insert,delte) 2. Prepare Scripts for those actions. B. Splitting an action: Navigation: Place cursor in desired location>Edit menu>action>split action>Enter Action 1 name & action 2 name. Steps: 1. Generate total test in the default action 2. Split into meaningful actions. Note: At a time we can split one actions into 2 actions. C. Renaming actions: Select desired action in action drop down box> edit menu>action>rename action>modify the name>click ok. D. Deleting Actions: Select desired action in action drop down box>edit menu>action>delete action>confirm deletion. E. Calling an action: Insert>call to existing action>browse path of the test>select desired action>click ok. Note: U can’t edit F. Copying an action: Insert>call to copy of action>browse path of the test>select desired action>click ok. Note: we can edit this action. G. Making an action reusable: Select Non Reusable action >edit >action>action properties>check reusable action check box >click ok. Regular Expressions www.GCREDDY.COM 44
  • 45. For QTP Scripts & Other Information visit: www.gcreddy.com We use regular expressions whenever object’s properties values are changing dynamically. Navigation: Open object repository >select the object>select the property value>click configure>check regular expression >enter expression [0-9] close repository. Note: 1. Always-regular expression we use brackets. 2. [A-Z] 3. [a-z] 4. [A-Z] [a-z] we can also use two expressions together [0-9] for one to 9 digits this is how we use [0-9]*for 2 digit numbers to be considered. For example use fax order Functions: Functions are Vbscript features; we use these for reusing components. Vbscript Procedures: In Vbscript there are 2 kinds of procedures available. 1. Sub procedures 2. Function procedures A. Sub Procedures: Sub procedure performs a task(s) but cannot return a value. Syntax: SUB Name of the procedure(arguments) Statements End Sub Note: Arguments are optional , We can give number of arguments by separating with commas. Ex: (a,b,c) Creating a Sub procedure Open an editor (notepad) Prepare test script Save as Dot.vbs file Ex: Sub login Invokeapplication "C:Program FilesHPQuickTest Professionalsamplesflightappflight4a.exe" dialog("text:=Login").Activate dialog("text:=Login").Winedit("attached text:=Agent Name:").Set "asdf" dialog("text:=Login").Winedit("attached text:=Password:").Set "mercury" www.GCREDDY.COM 45
  • 46. For QTP Scripts & Other Information visit: www.gcreddy.com dialog("text:=Login").Winbutton("text:=OK","width:=60").Click End Sub Associating a procedure to QTP. Navigation: File >settings>Resources>Click add icon>browse path of the library file>click apply>click ok Or Executefile “path of the library file” C:Documents and SettingspoojaDesktop/login.vbs” Calling a procedure: Call procedure name (ex Call login) Function Procedure (it returns a value) Function trigun(a,b,c) res=(a+b+c) trigun=res End Function x=trigun(100,200,300) msgbox x Environment Variables These are global variables; if you want to use some variables globally (From number of tests) declaring as global variables is better. If we declare as local variables in number of tests, modifications are difficult. Types of Environment variables: 1. Built in variables: These are system defined variables, we can access from all tests but these are designed as read only. 2. User defined variables: Variables that we predefine in the active external environment variables file. We can create as many files as we want and we can change values of variables. Usage of environment variables: Syntax: Variable = Environment(“environment variable name”) Ex: X=Environment (“ActionName”) Msgbox x Example Script: www.GCREDDY.COM 46
  • 47. For QTP Scripts & Other Information visit: www.gcreddy.com ProductDir =environment ("ProductDir") app= "samplesflightappflight4a.exe" Systemutil.Run ProductDir & app Dialog("Login").Activate Dialog("Login").WinEdit("Agent Name:").Set "kajal" Dialog("Login").WinEdit("Password:").SetSecure "4b3c86f2107ff565cc195ba6c24739091b656407" Dialog("Login").WinButton("OK").Click Creating user defined environment variables: Navigation: File>settings>environment>select variable type as user defined>click add icon (+)>enter variable name & Value>click ok (like this we can create number of variables)>click export >browse path & enter file name, save with xml extension.>click ok. Associating environment variable file: Navigation: file >settings>environment >select variable type as user defined>check “load variables and values from the external file”> browse path of the xml file >click apply & ok. Or We can load environment file directly Environment.loadfromfile”path of the xml file” Usage of user defined environment variables: Associate environment file to current test: Variable = Environment (“Variable Name”) X=environment (“city”) Msgbox x Modifying Environment files: Select XML file>open with notepad>modify the values>Save. Virtual object configuration It is a process of making the QTP to treat a specified area or an user defined object as a specific object. Navigation: Tools>virtual objects>virtual object manager>click new>click next>select class(ex button)>click next>click mark object>mark the area on AUT>click next>click next>enter collection name or project name>click finish>click close. www.GCREDDY.COM 47
  • 48. For QTP Scripts & Other Information visit: www.gcreddy.com Note: when you run and click on virtual object you will see as virtual button. Batch Testing or Batch execution Executing a group of tests at a time is known as batch execution. For performing batch execution QTP is providing a separate tool called test batch runner. Steps for Batch Testing: 4. Prepare individual tests and run once. 5. Open Test batch runner tool and form batches. 6. Execute Test batches from Test batch runner. Forming a Test Batch: Launch Test Batch Runner. Navigation: Start>program>quicktest professional>Tools>Test Batch Runner>File>new>batch>add>browse path of the test (like this add number of tests)>save with MTB extension (Module test batche)>close test batch runner. Running/Executing a Test Batch Open Test Batch Runner Tool Navigation: File>open>browse path of the test batch>batch>run Note: Test batch runner launches QTP Tool, QTP runs Tests one by one. Note: Allowing other products to run tests. Navigation: Tools>Options>Run>check allow other mercury products>apply & Ok Executing partial Test Batch Open Test Batch runner >open Test Batch>Select or deselect tests>run test batch. Dynamic Handling of Object Repositories We can handle the object repositories through scripting with the help of a utility object Repositoriescollection Ex RepPath1= "C:Documents and SettingsadminMy DocumentsLogin.tsr" RepPath2= "C:Documents and SettingsadminMy DocumentsOrders.tsr" Repositoriescollection.Add (RepPath1) www.GCREDDY.COM 48
  • 49. For QTP Scripts & Other Information visit: www.gcreddy.com SystemUtil.Run "C:Program FilesHPQuickTest Professionalsamplesflightappflight4a.exe" Dialog("Login").Activate Dialog("Login").WinEdit("Agent Name:").Set "asdf" Dialog("Login").WinEdit("Password:").Set "mercury" Dialog("Login").WinButton("OK").Click Pos=Repositoriescollection.Find(RepPath1) Repositoriescollection.Remove(Pos) Repositoriescollection.Add (RepPath2) Window("Flight Reservation").Activate Window("Flight Reservation").WinButton("New").Click Window("Flight Reservation").ActiveX("MaskEdBox").Type "101010" Window("Flight Reservation").WinComboBox("Fly From:").Select "London" Window("Flight Reservation").WinComboBox("Fly To:").Select "Denver" Window("Flight Reservation").WinButton("FLIGHT").Click Window("Flight Reservation").Dialog("Flights Table").Activate Window("Flight Reservation").Dialog("Flights Table").Activate Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "20289 LON 09:12 AM DEN 04:23 PM AA $112.20" Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click Window("Flight Reservation").WinEdit("Name:").Set "gcr" Window("Flight Reservation").WinButton("Insert Order").Click Window("Flight Reservation").Close Repositoriescollection.RemoveAll Repositoriescollection.Add (RepPath1) SystemUtil.Run "C:Program FilesHPQuickTest Professionalsamplesflightappflight4a.exe" Dialog("Login").Activate Dialog("Login").WinEdit("Agent Name:").Set "asdf" Dialog("Login").WinEdit("Password:").Set "mercury" Dialog("Login").WinButton("OK").Click Note 1: For loading repository file (Reposotoirescollection.Add “path of the Repository file”) Or Vairable =”path of the repository file” Reposotoriescollection.add (variable) Note 2: For finding repository position Variable =reposotoirescollection.find (“Path of the repository file”) Note 3: For removing a specific repository file. Repositoriescollection.remove (position) Note 4: For removing all loaded repositories Repositoriescollection.removeall www.GCREDDY.COM 49
  • 50. For QTP Scripts & Other Information visit: www.gcreddy.com Automation Framework Framework: It is a generic work (outline work) or a set of guidelines designed by experts to perform a task(s) in an effective, efficient and optimized way. Automation framework: It is a systematic approach developed by experts for automating any application. Types of Framework: 1. Linear framework or Record/Playback framework. 2. Modular framework 3. Keyword driven framework 4. Hybrid framework Linear framework: • Generating the basic test using recording feature • Enhancing the test using Tool features • Debugging the test if required • Running the test • Analyzing results • Sending defects Modular framework: • Generating the individual components for each and every task (Actions) • Making them as reusable components • Preparing the required driver scripts • Executing the Drivers • Analyzing the results. Keyword driven framework: • Creating the required Test Case file & storing it in the corresponding folder. • Creating the required shared repository files & storing them in the corresponding folder. • Creating the required library files and storing them in the corresponding folder. • Creating the required environment variable files and storing them in the corresponding folder. www.GCREDDY.COM 50
  • 51. For QTP Scripts & Other Information visit: www.gcreddy.com Note: In this framework we create required tests and make them as functions, In driver script we call required functions . In this framework we have 2 scripts only. 1. Initialization Script It launches QTP Tool and calls Driver Script 2. Driver script It executes all tests one by one. If we want to execute our desired tests, then we need to modify the Driver script only. Recovery Scenarios During the execution QTP may face some problematic situations where in it needs to recover by itself and continue the execution. To do the same the Test Engineer would have defined a solution well in advance and made it available to current test before starting the execution. QTP may face 4 types of problematic situations: 1. Problems related to path of the windows 2. problems related to object state 3. Problems related to Test execution 4. problems related to application crash To define a solution for the above problems QTP has provided 4 trigger events. 1. Popup window 2. Object State 3. Test runner error 4. Application Crash Creating a Recovery Scenario: Navigation: Resources menu>Recovery Scenario manager>click new scenario icon>Click Next>Select Trigger event(Test run error) >Click next>Select error type (item in list or menu not found)>click next>click next>select recovery operation(Function Call)>click next>browse path of function library(notepad)>click next >check another recovery operation if required>click next>select post recovery operation(proceed to next step)>click next>enter scenario name>click next>Check add scenario to current test if required>click finish>click save>click close. Editing a Recovery Scenario: www.GCREDDY.COM 51
  • 52. For QTP Scripts & Other Information visit: www.gcreddy.com Navigation: Resources menu>Recovery Scenario manager>click open>browse path of scenario file>Select scenario>click edit icon>click next(through navigating modify required values)>click finish>click save>click close. Data Table Methods Addsheet method Adds the specified sheet to the run-time Data Table and returns the sheet Syntax: Datatable.Addsheet “sheet name” DeleteSheet method Example1): datatable.AddSheet "gcr" datatable.ImportSheet "C:Documents and SettingsAdministratorDesktopgcreddy.xls",1,3 n=datatable.GetSheet (3).GetRowCount For i= 1 to n Datatable.SetCurrentRow(i) Invokeapplication "C:Program FilesHPQuickTest Professionalsamplesflightappflight4a.exe" Dialog("Login").Activate Dialog("Login").WinEdit("Agent Name:").Set datatable("agent",3) Dialog("Login").WinEdit("Password:").Set datatable("pwd",3) Dialog("Login").WinButton("OK").Click Window("Flight Reservation").Close Next Example 2): datatable.AddSheet "gcr" datatable.ImportSheet "C:Documents and SettingsAdministratorDesktopgcreddy.xls",1,3 n=datatable.GetSheet (3).GetRowCount For i= 1 to n datatable.SetCurrentRow(i) VbWindow("Form1").Activate VbWindow("Form1").VbEdit("val1").Set datatable("V1",3) VbWindow("Form1").VbEdit("val2").Set datatable("V2",3) VbWindow("Form1").VbButton("ADD").Click eres= Datatable.Value ("res",3) ares=VbWindow("Form1").VbEdit("res").GetROProperty ("text") If eres=ares Then datatable("res",3)=pass else datatable("res",3)=fail www.GCREDDY.COM 52
  • 53. For QTP Scripts & Other Information visit: www.gcreddy.com End If Next www.GCREDDY.COM 53