QuickTest Professional
QuickTest Professional 10.00
Product ID: QTPRPID 10.00/0
Version: 10.00.0.0
Build: 513
By www.gcreddy.com
Index
Basic Features of QTP
Key Elements of QTP
QTP Testing Process
Generating Tests
Enhancing Tests
Debugging & Running Tests
Actions
Functions
Regular Expressions
Environment Variables
I) Basic features of QTP
QTP Launched in 2002 (Nov). By Mercury Interactive. Later taken over by HP, in 2007.
QTP is an Object Based Testing Tool.
QTP is for functional and Regression Testing.
It follows Keyword driven approach.
It supports Windows Operating Environment only.
It supports GUI based (Graphical user interface) and Web based Applications Automation, does not support CUI (Command user interface) Applications.
It has multilingual support. (It supports English, Chinese, Japanese, Korean, etc languages with respect to license.)
It has adapted Microsoft Visual Basic Scripting edition for programming and excel like spread sheet for Data driven testing.
SQL (Structured query language) embedded or inserted with QTP, so we can use SQL statements directly from QTP.
It can be integrated with other Tools like WinRunner and Quality Center.
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.
It was derived from Astra QuickTest (mother tool of QTP).
It supports IE (Internet Explorer) only for recording tests, for execution it supports other browsers like Mozilla and AOL, opera Etc apart from IE.
QTP is a Desktop Application (I-Tier/Stand alone).
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.
QTP has UNI code support.
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.
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
II) Key Elements of QTP Tool Window
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.
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
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.
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.
Enter test data directly into Data Table and use.
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.
Global Sheet- for entire test /used for all actions in the test.
Action Sheets- for specific action only.
Data table available in 2 ways:
Design time data table. (Attached with every test)
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.
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)
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).
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.
Menu options
Tool Bar options
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).
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.
III) QTP Testing Process
Planning
Analyzing the AUT
Automation Test Plan Generation
Automation Framework Implementation
Generating/Selecting Test cases for Automation
Collecting Test Data
QTP Tool Settings Configuration
Generating Tests
Recording
Keyword driven methodology
Descriptive Programming
Enhancing Tests
Inserting Checkpoints
Inserting Output values
Adding Comments
Synchronization
Parameterization
Inserting Flow Control Statements
Calling User defined functions
Generating Steps though Step Generator
Inserting Transaction Points
Regular Expressions
Debugging Tests
Debug Commands & Break Points
Step by step execution
Watching Variables
Changing values of variables
Running Tests
Normal Execution
Batch Execution
AOM Scripting
Tests Running through framework
Scheduled Execution
Analyzing Results
QTP Result window
Defining our own Results
Exporting Results
Deleting Results
Reporting Defects
Manual Defect Reporting
Tool based Defect Reporting
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.
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):
Put AUT in base state
Select Record Option
It shows Record and Run Settings, Select type of Environment (Windows or Web)
Select Record Option
(It shows two Options :
Record and Run Test on any open window based applications
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.)
Click OK
Perform actions on AUT
Stop recording.
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:
Keep tool under recording mode
Automation >Analog Recording
OR
Use Short cut Key (Shift + ALT+F3)
Steps for preparing a TEST (through Analog Recording):
Launch AUT (or we can launch AUT through QTP)
Select Record option
Automation>Analog Recording
Analog Recording Settings Dialog box opens
(In this Dialog box two options available.
Record relative to the screen
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.)
Select any one option in the dialog box and click Start Analog record.
It records User actions
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:
Keep tool under recording mode
Automation >Low Level Recording
Steps for preparing a TEST (through Low Level Recording):
Launch AUT (or we can launch AUT through QTP)
Select Record option
Automation> Low Level Recording
Perform options on AUT
Stop Recording
Save the Test
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.
Run time objects
Test objects
Utility objects
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 windows Environment Test objects in VB
Environment Test objects in web 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.
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.
Local repository (.MTR extension)
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)
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
Selected object only
Default object types
All objects types
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.
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
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:
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)
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.
Static Programming
Dynamic Programming
Static Programming: In this style of script generation, we provide objects information directly into the script.
Ex:
Invokeapplication "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.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:
Dialog, WinEdit and WinButton – Test Objects
text, attached text - Property names
Login, Agent Name:, Password:, OK - Property values or Logical Names of the Object
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
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 Files\HP\QuickTest Professional\samples\flight\app\flight4a.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.
Inserting Check Points
Inserting Output Values
Adding Comments
Inserting Flow Control Statements
Synchronization
Parameterization
Generating Steps through Step Generator
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:
Standard check point
Text check point
Text area check point
Bit map check point
Data base check point
Accessibility check point
XML Check point (from application)
XML Check point (from resource)
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.
Through expert view, 2. Through keyword view, 3. Through Active screen.
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
(Match case, ignore spaces, exact match, text not displayed.)
We can select one or more options>click ok & stop recording.
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.
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.
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.
If an item is available, according to W3C rules then Pass.
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.
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.
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.
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.
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:
Standard output value
Text output value
Text area output value
Database output value
XML output value (From Application)
XML output value (From Resource)
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:
For making the script understandable
For making the Script Disable from execution
Syntax:
Use Apostrophe (‘) before the statement
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.
Inserting Wait statements.
Inserting Synchronization points.
Increasing Tool default synchronization time.
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:
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:
Suppose in our test one or more statements only are taking more time for execution then selecting “Inserting synchronization method” is better.
Suppose in our test more statements are taking more time for execution then selecting “increasing tool time out” .
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.
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.
Through Loop Statements
Dynamic Test Data Submission
Through Data Table
Fetching Test Data directly from External files (Flat files & Spreadsheets)
Fetching Test Data directly from Databases (MSAcess, oracle etc).
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 Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.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.
It has 3 types of usage .
Entering test data directly into data table and use
Importing test data from external Flat files
Importing test data from external Spread sheets
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 Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.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.
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.
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 Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","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")
Set rs=createobject("adodb.recordset")
con.provider=("microsoft.jet.oledb.4.0")
con.open "C:\Documents and Settings\pooja\My Documents\trigun.mdb"
rs.open "select * from login",con
do until rs.eof=true
SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"
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:
Step Into: (short cut key F11)
It starts execution
It executes one statement at a time.
If it is function call, it opens the function, after that it executes one statement at a time.
Step Over (Short cut key F10)
It executes one statement at a time after execution starts
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.
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"
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.
Watch
Variables
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.
Running the Test / Executing the Test
Normal execution/ General execution (Executing one test at a time)
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:
Prepare individual tests and run once.
Open Test batch runner tool and form batches.
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.
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.
Ex:
option explicit
Dim qtApp,qtTest
Set qtApp=createobject ("quicktest.application")
qtApp.Launch
qtApp.visible=True
qtApp.open "C:\Documents and Settings\admin\My Documents\login"
Set qtTest=qtApp.Test
qtTest.run
qtTest.close
qtApp.open "C:\Documents and Settings\admin\My Documents\open 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.
Executing Tests through Framework
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.
Analyzing the results:
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.
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 issue –Tracker or PR –Tracker, etc. After analyzing the results, open the TOOL, open the 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
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:
Create required actions(ex login, insert,delte)
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:
Generate total test in the default action
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
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:
Always-regular expression we use brackets.
[A-Z]
[a-z]
[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.
Sub procedures
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 Files\HP\QuickTest Professional\samples\flight\app\flight4a.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
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 Settings\pooja\Desktop/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:
Built in variables: These are system defined variables, we can access from all tests but these are designed as read only.
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:
ProductDir =environment ("ProductDir")app= "\samples\flight\app\flight4a.exe"
Systemutil.Run ProductDir & appDialog("Login").ActivateDialog("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.
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:
Prepare individual tests and run once.
Open Test batch runner tool and form batches.
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 Settings\admin\My Documents\Login.tsr"
RepPath2= "C:\Documents and Settings\admin\My Documents\Orders.tsr"
Repositoriescollection.Add (RepPath1)
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.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 Files\HP\QuickTest Professional\samples\flight\app\flight4a.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
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:
Linear framework or Record/Playback framework.
Modular framework
Keyword driven framework
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.
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.
Initialization Script
It launches QTP Tool and calls Driver Script
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:
Problems related to path of the windows
problems related to object state
Problems related to Test execution
problems related to application crash
To define a solution for the above problems QTP has provided 4 trigger events.
Popup window
Object State
Test runner error
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:
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 Settings\Administrator\Desktop\gcreddy.xls",1,3
n=datatable.GetSheet (3).GetRowCount
For i= 1 to n
Datatable.SetCurrentRow(i)
Invokeapplication "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.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 Settings\Administrator\Desktop\gcreddy.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
End If
Next
For QTP Scripts & Other Information visit: www.gcreddy.com
51
www.GCREDDY.COM