Documente Academic
Documente Profesional
Documente Cultură
Add-in Manager
Test Pane
QTP Commands
Recording Tests
Object Repository
Enhancing Tests
Inserting Checkpoints
Synchronization
Step Generator
Adding Comments
Debugging Tests
Running/Executing Tests
Reporting Defects
Actions
Functions
Environment Variables
Regular Expressions
Batching Testing
Recovery Scenarios
Database connections
Test Automation
Basically Software Testing is 2 types
1) Manual Testing
2) Test Automation
Manual Testing:
Testing software manually is called Manual Testing. we can test all accepts
of software manually.
Test Types:
a) Functional Testing
b) Regression Testing
c) GUI Testing
d) Usability Testing
e) Security Testing
f) Compatibility Testing
g) Recovery Testing
h) Reliability testing
Etc…
(i)Time consuming.
(ii) More resources required.
(iii)Human Errors
(iv)Repetition of the Task is not much
(v)Tiredness
(vi)Simultaneous auctions are not possible (Parallel)
Test Automation:
b) Load/Stress/Performance Testing
c) Security Testing
d) Unit Testing
Tests that use multiple data values (Retesting / Data Drives Testing)
Tests that required data from application intimates (G.U.I. Attributes) Load
and Stress Testing
(Object based means; QTP Follows Test Object Model for Performing Testing operations.
Based on either Test Objects or Automation Objects or Utility Objects only, we can
automate test operations)
(Basically QTP is a Functional and Regression Test tool but we can use it for little bit
Compatibility Testing and Performance Testing)
• It follows Keyword Driven Approach.
(QTP basically depends on User Interface to automate test operations and it is not depends
on server side interactions, where as LoadRunner depends on server side Operations, so HP
developed LoadRunner for Windows as well as UNIX versions)
• 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.
• VB Script engine integrated in QTP, so apart from scripting features we can use File
system, Excel, word, Adodb etc. Object models from QTP.
• SQL (Structured query language) engine integrated in QTP, so we can use SQL
Statements in QTP to perform Database Operations
• Excel like spread sheet integrated in QTP for performing Data driven Testing
• We can install MS Script Debugger with QTP for Debugging Test scripts.
• QTP uses XML format for Test results, Environment variables and for exporting object
repositories.
-------------------------------------------------------
• QTP can be integrated with other Tools like WinRunner and Quality Center.
• QTP 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 supports IE (Internet Explorer) only for recording tests, for execution it supports
other browsers like Mozilla and AOL, opera Etc apart from IE.
• 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.
• 6.5 – 2003
• 8.0 – 2004
• 9.0,9.1-2006
Overview
----------------------------------------------------------------
a) Disadvantages of Manual Testing
1) Huge Amount of Human Resources as well as Environment (Test lab)
3) Less Accuracy
4) Tideness
1) Fast
2) Reliable
3) Accurated
4) Reusable
5) Repeatable
6) Comprehensive
1) Expensive
2) Technical expertise
3) 100% Automation not Posible
---------------------------------------------------------------------------
II) QTP Test Process
---------------------------------------------------------------------------
--------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------
---
III) Test Execution
------------------- IIIA) Debugging Tests (Optional)
a) Forming Test Batches/suites a) Step by step execution
b) Test Environment setup b) Watching Variables
c) Test Execution c) Locating & Isolating Errors
d) Analyzing Test Results
d) Defect Reporting
e) Defect Tracking III B) Running Tests
f) Re & Regression Testing a) Single Test Run
g) Test status Reporing b) Batch Testing
h) Test Logs c) Executing Tests thru Framework
i) Final Regression d) Scheduled execution
e) Analyzing Results
f) Result Reporing
g) Defect Reporing
h) Regression Testing
-------------------------------------------------------------------------------------------
IV) Test Closure IV) Test Closure
-----------------
a) evaluating Exit Criteria a) Sending Test scripts & Resources to Customer
b) Collecting all facts from Test Activities b) Maintaning Tests & Resouce files
c) sending Test Delivarables to Customer c) Improvement Suggessions
d) Improvement Suggessions for QA Process
---------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------
2) Descriptive Programming
a) Static Programming
b) Dynamic programming
Recording Tests
----------------
a) Recording Process
b) Recording Modes
i) Normal Recording
ii) Analog Recording
iii) Low Level Recording
c) Running Process
Object Repository:
------------------
a) Object and Types of Object
i) Run-time Objects
ii) Test Object Model
iii) Utility Objects
iv) Automation Objects
i) Adding Objects
ii) Renaming Objects
iii) Deleting Objects
iv) Exporting Local Objects
v) Merging Repositories
vi) Associating Repositories to an Action
vii) View Options
viii) Exporting Objects to XML/Importing Objects from XML
iX) Defining New Test Objects
X) Spying Objects
i) Normal identification
1) Mandatory properties
2) Assistive properties
Descriptive programming:
------------------------
a) Static programming
b) Dynamic Programming
i) Creating Collection Objects
ii) Entering Properties Information into Collection Objects
iii) Using Collection Objects, generating tests
----------------------------------------------------------------------------------
QTP Add ins Info
This document provides QuickTest Professional add ins information like Activex, web, visual
basic, SAP, Java, .NET, People soft, TE, Web services and Oracle environments.
I) ActiveX Environment
Object Description
----------------------------------------------------
ActiveX An ActiveX control.
----------------------------------------------
AcxButton An ActiveX button.
-------------------------------------------------
AcxCalendar An ActiveX calendar object.
----------------------------------------------------
AcxCheckBox An ActiveX check box.
----------------------------------------------------
AcxComboBox An ActiveX combo box object.
--------------------------------------------------------
Object Description
-----------------------------------------
DelphiButton A Delphi button.
--------------------------------------------------
DelphiCheckBox A Delphi check box.
----------------------------------------------------
DelphiComboBox A Delphi combo box.
-----------------------------------------------------
DelphiEdit A Delphi edit box.
-----------------------------------------------------
DelphiEditor A Delphi multi-line editor.
-------------------------------------------------------------
DelphiList A Delphi list.
------------------------------------------------------------
DelphiListView A Delphi list-view control.
-------------------------------------------------------------
DelphiNavigator A Delphi navigator control.
--------------------------------------------------------------
DelphiObject A Delphi object.
--------------------------------------------------------------
DelphiRadioButton A Delphi radio button.
---------------------------------------------------------------
DelphiScrollBar A Delphi scroll bar.
------------------------------------------------------
DelphiSpin A Delphi spin box.
-----------------------------------------------------
DelphiStatic A Delphi static control.
-----------------------------------------------------------
DelphiStatusBar A Delphi status bar.
-------------------------------------------------------------
DelphiTable A Delphi table.
------------------------------------------------------------
DelphiTabStrip A Delphi tab strip.
-----------------------------------------------------------
DelphiTreeView A Delphi tree-view control.
------------------------------------------------------------
DelphiWindow A Delphi window or dialog box.
***************************************************
Object Description
JavaApplet Java applet.
------------------------------------
JavaButtonA Java button.
-----------------------------------------
JavaCalendar A Java calendar.
-----------------------------------------
JavaCheckBox A Java check box.
-----------------------------------------
JavaDialog A Java dialog box.
--------------------------------------------
JavaEdit A Java edit box.
-------------------------------------------
JavaExpandBar A Java control that contains labeled bar items, which can be expanded
or collapsed by the user.
--------------------------------------------------------
JavaInternalFrame An internal frame that can be activated from the Java applet.
----------------------------------------------------------
JavaLink A Java control that displays text with links.
-----------------------------------------------------------------
JavaList A Java list box with single or multiple selection.
--------------------------------------------------------------------
JavaMenu A Java menu item.
-----------------------------------------------------
JavaObject A generic Java object.
---------------------------------------------
JavaRadioButton A Java radio button.
--------------------------------------------
JavaSlider A Java slider.
-------------------------------------------
JavaSpin A Java spin object.
-------------------------------------------
JavaStaticText A Java static text object.
------------------------------------------------------
JavaTab A Java tabstrip control containing tabbed panels.
----------------------------------------------------------------
JavaTable A Java table.
---------------------------------
JavaToolbar A Java toolbar.
-----------------------------------
JavaTree A Java tree.
-----------------------------
JavaWindow A Java window.
---------------------------------------
******************************************
IV) .NET Web Forms Environment
Object Description
--------------------------------------
WbfCalendar A .NET Web Forms calendar control.
----------------------------------------------------------------
WbfGrid A .NET Web Forms DataGrid object.
----------------------------------------------------------------
WbfTabStrip A .NET Web Forms tabstrip control.
--------------------------------------------------------------
WbfToolbar A .NET Web Forms toolbar control.
-------------------------------------------------------------
WbfTreeView A .NET Web Forms tree view object.
-------------------------------------------------------------
WbfUltraGrid A .NET Web Forms UltraGrid object.
**************************************************
Object Description
---------------------------------
SwfButton
A .NET Windows Forms button object.
SwfCalendar
A DateTimePicker or a Month Calendar .NET Windows Forms calendar object.
SwfCheckBox
A .NET Windows Forms check box.
SwfComboBox
A .NET Windows Forms combo box.
SwfEdit
A .NET Windows Forms edit box.
SwfEditor
A .NET Windows Forms multi-line edit box.
SwfLabel
A .NET Windows Forms static text object.
SwfList
A .NET Windows Forms list.
SwfListView
A .NET Windows Forms ListView control.
SwfObject
A standard .NET Windows Forms object.
SwfPropertyGrid
A property grid control based on the .NET Windows Forms library.
SwfRadioButton
A .NET Windows Forms radio button.
SwfScrollBar
A .NET Windows Forms scroll bar.
SwfSpin
A .NET Windows Forms spin object.
SwfStatusBar
A .NET Windows Forms status bar control.
SwfTab
A .NET Windows Forms tab control.
SwfTable
A grid control based on the .NET Windows Forms library.
SwfToolBar
A .NET Windows Forms toolbar.
SwfTreeView
A .NET Windows Forms TreeView control.
SwfWindow
A .NET Windows Forms window.
Object Description
WpfButton
A button control in a Windows Presentation Foundation application.
WpfCheckBox
A check box control in a Windows Presentation Foundation application.
WpfComboBox
A combo box control in a Windows Presentation Foundation application.
WpfEdit
A document, rich text box, or text control in a Windows Presentation Foundation application.
WpfGrid
A grid control in a Windows Presentation Foundation application.
WpfImage
An image control in a Windows Presentation Foundation application.
WpfLink
A hyperlink control in a Windows Presentation Foundation application.
WpfList
A list control in a Windows Presentation Foundation application.
WpfMenu
A menu control in a Windows Presentation Foundation application.
WpfObject
An object control in a Windows Presentation Foundation application.
WpfProgressBar
A progress bar control in a Windows Presentation Foundation application.
WpfRadioButton
A radio button control in a Windows Presentation Foundation application.
WpfScrollBar
A scroll bar control in a Windows Presentation Foundation application.
WpfSlider
A slider control in a Windows Presentation Foundation application.
WpfStatusBar
A status bar control in a Windows Presentation Foundation application.
WpfTabStrip
A tab control in a Windows Presentation Foundation application.
WpfToolbar
A toolbar control in a Windows Presentation Foundation application.
WpfTreeView
A tree control in a Windows Presentation Foundation application.
WpfWindow
A window control in a Windows Presentation Foundation application.
Object Description
OracleApplications
An Oracle Applications session window.
OracleButton
An Oracle button.
OracleCalendar
An Oracle calendar.
OracleCheckbox
A check box Oracle field.
OracleFlexWindow
An Oracle flexfield window.
OracleFormWindow
An Oracle Form window.
OracleList
An Oracle poplist (combo box) or list.
OracleListOfValues
An Oracle window containing a list of values for selection.
OracleLogon
An Oracle Applications sign-on window.
OracleNavigator
An Oracle Navigator window.
OracleNotification
An Oracle error or message window.
OracleRadioGroup
An Oracle option (radio button) group.
OracleStatusLine
The status line and message line at the bottom of an Oracle Applications window.
OracleTabbedRegion
An Oracle tabbed region.
OracleTable
An Oracle block of records.
OracleTextField
An Oracle text field.
OracleTree
An Oracle tree.
Object Description
PSFrame
A frame object within a PeopleSoft application.
Object Description
PbButton
A PowerBuilder button.
PbCheckBox
A PowerBuilder check box.
PbComboBox
A PowerBuilder combo box.
PbDataWindow
A PowerBuilder DataWindow control.
PbEdit
A PowerBuilder edit box.
PbList
A PowerBuilder list.
PbListView
A PowerBuilder listview control.
PbObject
A standard PowerBuilder object.
PbRadioButton
A PowerBuilder radio button.
PbScrollBar
A PowerBuilder scroll bar.
PbTabStrip
A PowerBuilder tab strip control
PbTreeView
A PowerBuilder tree-view control.
PbWindow
A PowerBuilder window.
Object Description
SAPButton
An SAP Gui for HTML application button, including icons, toolbar buttons, regular buttons,
buttons with text, and buttons with text and image.
SAPCalendar
A calendar in a Web-based SAP application.
SAPCheckBox
An SAP Gui for HTML application toggle button, including check boxes and toggle images.
SAPDropDownMenu
A menu that is opened by clicking a menu icon within an SAP Gui for HTML application.
SAPEdit
An SAP Gui for HTML application edit box, including single-line edit boxes and multi-line edit
boxes (text area).
SAPFrame
An SAP Gui for HTML application frame.
SAPiView
An SAP Enterprise Portal application iView frame.
SAPList
A drop-down or single/multiple selection list in an SAP Gui for HTML application.
SAPMenu
An SAP Gui for HTML application top-level menu.
SAPNavigationBar
A navigation bar in a Web-based SAP application.
SAPOKCode
An OK Code box in an SAP Gui for HTML application.
SAPPortal
An SAP Enterprise Portal desktop.
SAPRadioGroup
An SAP Gui for HTML application radio button group.
SAPStatusBar
An SAP Gui for HTML application status bar.
SAPTable
An SAP Gui for HTML application table or grid.
SAPTabStrip
An SAP Gui for HTML application tab strip object (an object that enables switching between
multiple tabs).
SAPTreeView
An SAP Gui for HTML application tree object.
Object Description
SAPGuiAPOGrid
An APO grid control in an SAP GUI for Windows application.
SAPGuiButton
A button in an SAP GUI for Windows application.
SAPGuiCalendar
A calendar object in an SAP GUI for Windows application.
SAPGuiCheckBox
A check box in an SAP GUI for Windows application.
SAPGuiComboBox
A combo box in an SAP GUI for Windows application.
SAPGuiEdit
An edit box in an SAP GUI for Windows application.
SAPGuiElement
Any object in an SAP GUI for Windows application.
SAPGuiGrid
A grid control in an SAP GUI for Windows application.
SAPGuiLabel
A static text label in an SAP GUI for Windows application.
SAPGuiMenubar
A menu bar in an SAP GUI for Windows application.
SAPGuiOKCode
An OK Code box in an SAP GUI for Windows application.
SAPGuiRadioButton
A radio button in an SAP GUI for Windows application.
SAPGuiSession
Represents the SAP GUI for Windows session on which an operation is performed.
SAPGuiStatusBar
A status bar in an SAP GUI for Windows application.
SAPGuiTable
A table control in an SAP GUI for Windows application.
SAPGuiTabStrip
A tab strip in an SAP GUI for Windows application.
SAPGuiTextArea
A text area in an SAP GUI for Windows application.
SAPGuiToolbar
A toolbar in an SAP GUI for Windows application.
SAPGuiTree
A column tree, list tree, or simple tree control in an SAP GUI for Windows application.
SAPGuiUtil
A utility object in an SAP GUI for Windows application.
SAPGuiWindow
A window or dialog box containing objects in an SAP GUI for Windows application.
Object Description
SblAdvancedEdit
An edit box whose value can be set by a dynamic object that opens after clicking on a
button inside the edit box
SblButton
A Siebel button.
SblCheckBox
A check box with an ON and OFF state.
SblEdit
An edit box.
SblPickList
A drop-down pick list.
SblTable
A Siebel table containing a variable number of rows and columns.
SblTabStrip
A number of tabs and four arrows that move its visible range to the left and to the right.
SblTreeView
A tree view of specific screen data.
SiebApplet
An applet in a Siebel test automation environment.
SiebApplication
An application in a Siebel test automation environment.
SiebButton
A button control in a Siebel test automation environment.
SiebCalculator
A calculator control in a Siebel test automation environment.
SiebCalendar
A calendar control in a Siebel test automation environment.
SiebCheckbox
A checkbox in a Siebel test automation environment.
SiebCommunicationsToolbar
The communications toolbar in a Siebel test automation environment.
SiebCurrency
A currency calculator in a Siebel test automation environment.
SiebList
A list object in a Siebel test automation environment.
SiebMenu
A menu or menu item in a Siebel test automation environment.
SiebPageTabs
A page tab in a Siebel test automation environment.
SiebPDQ
A predefined query in a Siebel test automation environment.
SiebPicklist
A pick list in a Siebel test automation environment.
SiebRichText
A rich text control in a Siebel test automation environment.
SiebScreen
A screen object in a Siebel test automation environment.
SiebScreenViews
A screen view in a Siebel test automation environment.
SiebTaskAssistant
The Task Assistant in a Siebel test automation environment.
SiebTaskUIPane
The task UI pane in a Siebel test automation environment.
SiebText
A text box in a Siebel test automation environment.
SiebTextArea
A text area in a Siebel test automation environment.
SiebThreadbar
A threadbar in a Siebel test automation environment.
SiebToolbar
A toolbar in a Siebel test automation environment.
SiebTree
A tree view object in a Siebel test automation environment.
SiebView
A view object in a Siebel test automation environment.
SiebViewApplets
A view applet in a Siebel test automation environment.
Object Description
Desktop
An object that enables you to access top-level items on your desktop.
Dialog
A Windows dialog box.
Static
A static text object.
SystemUtil
An object used to control applications and processes during a run session.
WinButton
A Windows button.
WinCalendar
A Windows calendar.
WinCheckBox
A Windows check box.
WinComboBox
A Windows combo box.
Window
A standard window.
WinEdit
A Windows edit box.
WinEditor
A Windows multi-line editor.
WinList
A Windows list.
WinListView
A Windows list-view control.
WinMenu
A Windows menu.
WinObject
A standard (Windows) object.
WinRadioButton
A Windows radio button.
WinScrollBar
A Windows scroll bar.
WinSpin
A Windows spin box.
WinStatusBar
A Windows status bar.
WinTab
A Windows tab strip in a dialog box.
WinToolbar
A Windows toolbar.
WinTreeView
A Windows tree-view control.
Object Description
WinTab
A Windows tab strip in a dialog box.
WinTable
A Stingray grid.
WinToolbar
A Windows toolbar.
WinTreeView
A Stingray tree control.
XV) Terminal Emulators Environment
Object Description
TeField
A terminal emulator field that fully supports HLLAPI.
TeScreen
A terminal emulator screen that fully supports HLLAPI.
TeTextScreen
A terminal emulator screen that uses text-only HLLAPI or does not support HLLAPI.
TeWindow
A terminal emulator window.
Object Description
VbButton
A Visual Basic button.
VbCheckBox
A Visual Basic check box.
VbComboBox
A Visual Basic combo box.
VbEdit
A Visual Basic edit box.
VbEditor
A Visual Basic multi-line editor.
VbFrame
A Visual Basic frame.
VbLabel
A static text object.
VbList
A Visual Basic list.
VbListView
A Visual Basic list-view control.
VbRadioButton
A Visual Basic radio button.
VbScrollBar
A Visual Basic scroll bar.
VbToolbar
A Visual Basic toolbar.
VbTreeView
A Visual Basic tree-view control.
VbWindow
A Visual Basic window.
Object Description
WinButton
A button in the VisualAge Smalltalk application.
WinEdit
An edit box in the VisualAge Smalltalk application.
WinList
A list in the VisualAge Smalltalk application.
WinObject
An object in the VisualAge Smalltalk application.
WinTab
A tab strip in the VisualAge Smalltalk application.
WinTable
A table in the VisualAge Smalltalk application.
WinTreeView
A tree-view control in the VisualAge Smalltalk application.
Object Description
Browser
A Web browser (or browser tab).
Frame
An HTML frame.
Image
An image with or without a target URL link.
Link
A hypertext link.
Page
An HTML page.
ViewLink
A Viewlink object.
WebArea
A section of an image (usually a section of a client-side image map).
WebButton
An HTML button.
WebCheckBox
A check box with an ON and OFF state.
WebEdit
An edit box, usually contained inside a form.
WebElement
A general Web object that can represent any Web object.
WebFile
An edit box with a browse button attached, used to select a file from the File dialog box.
WebList
A drop-down box or multiple selection list.
WebRadioGroup
A set of radio buttons belonging to the same group.
WebTable
A table containing a variable number of rows and columns.
WebXML
An XML document contained in a Web page.
Object Description
Attachments An object that supports attachment-related operations
-----------------------------------------------------------------------------------------
Configuration An object that supports configuration-related operations
-----------------------------------------------------------------------------------------
headers
An object that supports header-related test object operations.
Security
An object that supports security-related test object operations.
WebService
A test object representing a Web service.
WSUtil
A utility object used to check WSDL files.
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.
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.
Note 1: Generally novice testers use this feature but it occupies lot of
memory space on QTP.
3) Data Table
It has an integrated spread sheet (Excel like), used for Data driven testing.
2. Importing data from external files (Flat files, excel sheets, etc) and Data
bases (MS access, Sql Server, oracle, etc.)
1). Global Sheet- for entire Test /used for all actions in the Test.
2). Action Sheets- for specific Action only.
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)
5) Missing Resources
It can be used for showing missing resources that attached to current test
such as (Recovery Scenarios, Library files etc).
6) Information
This pane shows syntax errors automatically during saving the test.
Navigation: view menu> information
7) QTP Commands
QTP Commands are available in 3 ways.
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:
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.
QTP Commands
QTP Commands
1.Menu options
File menu: Through file menu user can create, save tests, open existing tests, export tests
in zip format.
Command Function
New > Test Creates a new test.
Export Test to Zip File Creates a zip file of the active document.
Edit Menu: It provides editing options and renaming, deleting and splitting actions.
Command Function
Undo Reverses the last command or deletes the
last entry you typed.
Redo Reverses the most recent operation of the
Undo command.
Action > Split Action Separates an action into two sibling actions
or into parent-child nested actions.
Action > Delete Action Enables you to remove the selected call to
the action, or delete the action and its calls
from the active test.
Action > Action Call Enables you to specify the number of run
Properties iterations according to the number of rows in
the Data Table, and to define the values of
input parameters and the storage location of
output parameters.
Step Properties > Opens the Comment Properties dialog box for
Comment Properties a comment step. Available only when the
selected step is a comment.
Step Properties > Opens the Object Properties dialog box for a
Object Properties selected object. Available only when the
selected step contains a test object.
Step Properties > Displays the Report Properties dialog box for
Report Properties a report step. Available only when the
selected step is a Reporter.ReportEvent
step.
Advanced > Indent Indents the step according to the tab spacing
defined in the Editor Options dialog box.
Advanced > Complete Completes the word when you type the
Word beginning of a VBScript method or object.
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.
Command Function
Record Starts a recording session.
Resources Menu:
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.
Command Function
Object Repository Opens the Object Repository window, which
displays a tree containing all objects in the
current test or component.
Debug Menu:
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.
Command Function
Options Opens the Options dialog box, enabling you to modify
global testing options.
View Options Opens the Editor Options dialog box, enabling you to
customize how tests and function libraries are
displayed in the Expert View and Function Library
windows.
Object Spy Opens the Object Spy dialog box, enabling you to view
the native properties and operations of any object in
an open application, as well as the test object
hierarchy, identification properties, and operations of
the test object that QuickTest uses to represent that
object.
Data Driver Opens the Data Driver dialog box, which displays the
default Constants list for the action. (Relevant for tests
only)
Virtual Objects > Opens the Virtual Object Wizard, enabling you to teach
New Virtual Object QuickTest to recognize an area of your application as
a standard test object.
Virtual Objects > Opens the Virtual object Manager, enabling you to
Virtual Object manage all of the virtual object collections defined on
Manager your computer.
Window Menu:
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.
1) Planning
2) Generating Tests
o Recording
o Keyword driven methodology
o Descriptive Programming
3) 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 and/or Reusable Actions
o Generating Steps though Step Generator
o Inserting Transaction Points
o Regular Expressions
4) Debugging Tests
5) Running Tests
o Normal Execution
o Batch Execution
o Through AOM Scripting
o Tests Running through framework
o Scheduled Execution
6) Analyzing Results
7) Reporting Defects
iii) Comments
Examples:
Option Explicit
Wait (14)
Recording Tests
During Running QTP reads statements one by one and gets Object Information from the
Object Repository, based on that Information performs operations on AUT.
c) Recording Modes
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)
5.Click OK
6.Perform actions on AUT
7.Stop recording.
8.Save the Test
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:
(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
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
d) Disadvantages of Recording
• It is used for Analyzing the AUT in the initial stage to find out weather the QTP tool is
Recognizing all of our Application Objects or not
Keyword-Driven Methodology
In this step, we build one or more object repositories and ensure that all
objects have clear names that follow any predetermined naming conventions
defined by our organization.
Ensure that objects in the object repository have names that are easy for
application testers to recognize and that follow any established object
naming guidelines.
This helps make both test creation and maintenance easier over time.
We need to specify configuration settings that affect how we create and run
tests in general—these settings are not test-specific.
We may perform the following tasks when creating tests and test steps:
Create new tests, if needed. To do so, select File > New > Test.
Associate our function libraries with the relevant tests. This enables us to
use our special keywords in any of the associated tests
The test object model is a large set of object types or classes that QuickTest uses to
represent the objects in your application. Each test object class has a list of identification
properties that QuickTest can learn about the object, a sub-set of these properties that can
uniquely identify objects of that class, and a set of relevant operations that QuickTest can
perform on the object.
A test object is an object that QuickTest creates in the test to represent the actual object in
your application. QuickTest stores information on the object that will help it identify and
check the object during the run session.
A run-time object is the actual object in your application on which methods are performed
during the run session.
When QuickTest learns an object in our application, it adds the corresponding test object to
an object repository, which is a storehouse for objects. we can add test objects to an object
repository in several ways.
• Identifies the QuickTest test object class that represents the learned object and creates
the appropriate test object.
• Reads the current value of the object's properties in your application and stores the list
of identification properties and values with the test object.
• Chooses a unique name for the test object, generally using the value of one of its
prominent properties.
The identification property set for each test object is created and maintained by QuickTest.
The native property set for each run-time object is created and maintained by the object
creator (for example, Microsoft for Microsoft Internet Explorer objects, Netscape for
Netscape Browser objects, the product developer for ActiveX objects, and so on).
Similarly, a test object operation is a method or property that QuickTest recognizes as
applicable to a particular test object class. For example, the Click method is applicable to a
WebButton test object. As you add steps to your test, you specify which operation to
perform on each test object. If you record steps, QuickTest records the relevant operation
as it is performed on an object.
During a run session, QuickTest performs the specified test object operation on the run-time
object. Native operations are the methods of the object in your application as defined by the
object creator.
Property values of objects in your application may change dynamically each time your
application opens, or based on certain conditions. You may need to modify the identification
property values to match the native property values. You can modify identification
properties manually while designing your test, or use SetTOProperty statements during a
run session. You can also use regular expressions to identify property values based on
conditions or patterns you define, or you can parameterize property values with Data Table
parameters so that a different value is used during each iteration of the test. For more
information on modifying object properties, see Managing Test Objects in Object
Repositories.
You can view or modify the identification property values that are stored with your test in
the Object Properties or Object Repository dialog box. For more information, see Specifying
or Modifying Property Values.
We can view the current identification property values of any object on your desktop using
the Properties tab of the Object Spy. For more information, see Viewing Object Properties
and Operations Using the Object Spy.
We can view the syntax of the test object operations as well as the native operations of any
object on your desktop using the Operations tab of the Object Spy. For more information,
see Viewing Object Properties and Operations Using the Object Spy.
We can retrieve or modify property values of the test object during the run session by
adding GetTOProperty and SetTOProperty statements in the Keyword View or Expert View.
We can retrieve property values from the run-time object during the run session by adding
GetROProperty statements. For more information, see Retrieving and Setting Identification
Property Values.
If the available test object operations and identification properties for a test object do not
provide the functionality you need, you can access the internal operations and properties of
the run-time object using the Object property. You can also use the attribute object
property to identify Web objects in your application according to user-defined properties.
For information, see Accessing Native Properties and Operations.
Objects can be stored in two types of object repositories—a shared object repository and a
local object repository. A shared object repository stores objects in a file that can be
accessed by multiple tests (in read-only mode). A local object repository stores objects in a
file that is associated with one specific action, so that only that action can access the stored
objects.
When you plan and create tests, you must consider how you want to store the objects in
your tests. You can store the objects for each action in its corresponding local object
repository, or you can store the objects in your tests in one or more shared object
repositories. By storing objects in shared object repositories and associating these
repositories with your actions, you enable multiple actions to use the objects. For each
action, you can use a combination of objects from your local and shared object repositories,
according to your needs. You can also transfer local objects to a shared object repository, if
required. This reduces maintenance and enhances the reusability of your tests because it
enables you to maintain the objects in a single, shared location instead of multiple locations.
For more information, see Deciding Whether to Use Local or Shared Object Repositories.
If you are new to using QuickTest, you may want to use local object repositories. In this
way, you can record and run tests without creating, choosing, or modifying shared object
repositories because all objects are automatically saved in a local object repository that can
be accessed by its corresponding action. If you modify an object in the local object
repository, your changes do not have any effect on any other action or any other test
(except tests that call the action, as described in Inserting Calls to Existing Actions).
If you are familiar with testing, it is probably most efficient to save objects in a shared
object repository. In this way, you can use the same shared object repository for multiple
actions—if the actions include the same objects. Object information that applies to many
actions is kept in one central location. When the objects in your application change, you can
update them in one location for all the actions that use this shared object repository.
If an object with the same name is located in both the local object repository and in a
shared object repository associated with the same action, the action uses the local object
definition. If an object with the same name is located in more than one shared object
repository associated with the same action, the object definition is used from the first
occurrence of the object, according to the order in which the shared object repositories are
associated with the action. For more information on associating shared object repositories,
see Associating Object Repositories with Actions.
Local objects are saved locally with the action, and can be accessed only from that action.
When using a shared object repository, you can use the same object repository for multiple
actions. You can also use multiple object repositories for each action.
When you open and work with an existing test, it always uses the object repositories that
are specified in the Associated Repositories tab of the Action Properties dialog box or in the
Associate Repositories dialog box. Shared object repositories are read-only when accessed
from tests; you edit them using the Object Repository Manager.
Object Repository
Object Repository:
It is a storage place of QTP where objects information can be stored 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, Web Pages, Buttons, Edit boxes, Check boxes etc.. as software 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.
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
User can create objects; those can be used for performing specific operations. Ex: Creating
objects in filesystemobject class, adodb.connection class, dictionary object class, Excel.
Application class etc.
Local Repository:
QTP creates a Local Repository for every Action automatically during Recording. That cannot
be shared among tests.
User can perform rename, delete operations on local repository. As it is QTP internal file
user no need to save modifications.
Shared Repository:
User (Test Engineer) creates the Shared Repository by adding objects. That can be shared
among number of tests.
B. Shared Repository:
(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:
Deleting Objects
a. Local Repository:
Resources > object repository >select object and right click >choose delete option >confirm
deletion>. >close repository
b. Shared Repository:
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.
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: File >export Test objects to XML Enter the file name and Save with xml
extension.
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
a) Normal identification
1) Mandatory properties
2) Assistive properties
b) Smart identification
c) Ordinal identifier
1) location
2) index
3) creation time(only for web)
First of all the qtp learns all the mandatory properties at a time and thinks
whether these properties sufficient to identify the object uniquely. if it feels
sufficient then it stops learning otherwise,
It learns first assistive property and once again stops and thinks, like this
qtp learns one by one. At the end of assistive properties list also if it feels
not satisfied and it finally goes to Ordinal Identifier.
After normal identification if qtp feels not satisfied then it goes to smart
identification. in smart identification 2 types of properties available, first qtp
learns all base filter properties at a time and thinks whether these properties
are sufficient for identifying the object uniquely. If it feels sufficient, then it
stops learning otherwise it goes Optional Filter Properties and learns one by
one. Still it feels not satisfied finally it goes to Ordinal Identifier.
Ordinal identifiers:
1) Location: is based on object location in the AUT ,location starts from zero.
For making tool settings global, QTP is providing a special feature called
"Generate Script".
STEPS:
a) File->Settings
b) Tools->Options
c) Tools->Object Identification
3) Share Script files to team members and ask them to execute those
scripts.
NOTE: After executing these scripts all team members can get same
settings.
QTP Methods
Activate: It activates dialog boxes/Windows
Syntax: Object hierarchy. Activate
Ex:
Dialog(“Login”).Activate
Window(“Flight Reservation”).Activate
Select Method:
It is used for selecting an item from a combo box or list box.
Syntax: Object hierarchy.select “item”
Ex:
Window("Flight Reservation").WinComboBox("Fly From:").Select "London"
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "12572
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
We can use this method to “delete” one specified sheet from the Run Time Data table.
(3) GetSheetCount
We can use this method to count number of sheets in the run time data table.
Syntax:
datatable.GetSheetCount
msgbox datatable.GetSheetCount
(4) GetRowCount
We can use this method to count number of rows in the 1st sheet
(longest column) of the Run time data table.
Syntax: datatable.GetRowCount
(5) GetSheet
We can use this method to return a specified sheet from the Run Time data table.
Syntax: datatable.GetSheet(SheetID)
(6) Value
We can use this method to set or get value of cell in the specified parameter and the current
row of the Rum time data table.
To set data
To get data
Ex:
(7) SetCurrentRow
We can use this method to take a specified row as current row in the Run Time Datatable
(By default it is 1st Row of 1st Sheet)
Syntax: datatable.SetCurrentRow(Row_Number)
g="gcreddy"
datatable.SetCurrentRow (3) datatable.Value (1,1) = g
(8) SetNextRow
We can use this method to take the row after the current Row as New Current Row in the
Run time data table.
Syntax: datatable.SetNextRow
Ex: g="gcreddy"
We can use this method to take the row before the current Row as New Current Row in the
Run time data table.
Syntax: datatable.SetPrevRow
Ex: g="gcreddy"
(10) Import
We can use this method to import Microsoft Excel File to the Runtime Data Table (Including
all sheets)
11) ImportSheet
We can use this method to import a specified sheet of Microsoft Excel Sheet to the Runtime
Data table.
(12) Export
We can use this method to export a copy of Run Time Data table to another location
(Including all sheets)
13) ExportSheet
We can use this method to export a copy specified sheet of Run Time Data table to the
existing or new Excel File.
**********************
Data Driven Testing for Login Operation using Data Table methods
Datatable.AddSheet "Login"
Datatable.ImportSheet "C:\Documents and Settings\gcr\Desktop\gcreddy.xls",1,3
Rows_count=Datatable.GetSheet(3).GetRowCount
For i= 1 to Rows_count
Datatable.SetCurrentRow(i)
SystemUtil.Run "C:\Program Files\HP\QuickTest
Professional\samples\flight\app\flight4a.exe","","C:\Program Files\HP\QuickTest
Professional\samples\flight\app\","open"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set Datatable("Agent",3)
Dialog("Login").WinEdit("Password:").Set Datatable("Pwd",3)
Dialog("Login").WinButton("OK").Click
Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
Dialog("Login").WinButton("Cancel").Click
End If
If Window("Flight Reservation").Exist(3)Then
Window("Flight Reservation").Close
End if
Next
Descriptive Programming
Descriptive Programming
Entering / Providing objects information directly into the test script is called Descriptive
Programming.
Advantages:
a) Descriptive Programming based Test scripts are faster in execution than Repository
based Test scripts.
b) Scripts are portable (we can run these scripts from any machine easily)
d) We can start Test Execution process even though Application is not ready.
1. Static Programming
2. Dynamic Programming
Static Programming
In this style of script generation, we provide objects information directly into the script.
Example:
1) Invokeapplication "C:\Program Files\HP\QuickTest
Professional\samples\flight\app\flight4a.exe"
2) dialog("text:=Login").Activate
3) dialog("text:=Login").Winedit("attached text:=Agent Name:").Set "gcreddy"
4) dialog("text:=Login").Winedit("attached text:=Password:").Set "mercury"
5) 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.
Example 2:
SystemUtil.Run "C:\Program Files\Internet Explorer\IEXPLORE.EXE","","C:\Program
Files\Internet Explorer","open"
Browser("title:=Google").Page("title:=Google").Sync
Browser("title:=Google").Navigate "http://www.icicibank.com/"
-------------------------------------------------------------------
If we want maintain ‘Objects information’ in centralized location then we can use Constants.
Steps:
Creating Constants:
Note: we can declare no of Constants in a line by separating with Camas (,), if we take
other line then we have to use Const Statement again.
Associate the Library file to QTP (File->Settings->Resources-> Click add (+) icon-> Browse
path of the Library file->Click Apply and click Ok buttons
Syntax:
Advantages:
Dynamic Programming
In this style of script generation, first we create description objects, provide properties
information and use description objects in the test script.
Set oLogin=description.Create
Set oAgent=description.Create
Set oPassword=description.Create
Set oOk=description.Create
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"
Dialog(oLogin).Activate
Dialog(oLogin).Winedit(oAgent).Set "gcreddy"
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.
------------------------------------------------------
Examples:
Handling similar/Duplicate Objects using Index Property
Browser("name:=Google").Page("title:=Google").Sync
Browser("name:=Google").Navigate http://www.jjperfumes.com/
Browser("name:=JJ Perfumes-Discount perfume cheap brand name perfumes, fragrance &
cologne online").page("title:=JJ Perfumes-Discount perfume cheap brand name perfumes,
fragrance & cologne online").Link("innertext:=Register","index:=0").Click
Inserting Checkpoints
Inserting Checkpoints
Check point is a verification point, it takes expected result from the user and compares with
actual results during execution and provides test results.
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.
Keep tool under recording mode > place cursor in desired location > Insert > check point >
Standard checkpoint > Show the object > click okay > select property and enter expected
results & click Ok and stop Recording.
Select Checkpoint statement and right click > choose checkpoint properties option > modify
the value > click Ok.
Select Checkpoint statements and right click > choose delete option.
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.
2) Text Checkpoint:
Navigation:
Keep tool under Recording mode >Insert menu > checkpoint > Text checkpoint > Show the
object > click ok > Select options
We can select one or more options > click ok & stop Recording.
Navigation:
Keep tool under Recording mode > Insert menu> Checkpoint > Text area checkpoint >
Mark the area of text > select one or more options
4. Bitmap checkpoint:
It compares bitmaps; we can compare complete bitmaps as well as part of the bitmaps.
Navigation:
Keep tool under Recording mode > Insert menu > 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:
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 tool under Recording mode and we do not need AUT since
data is from backend.
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.
Tools menu> options >web > advanced > check/uncheck items > click apply > click ok
Invigilation:
Result Criteria:
Navigation:
Keep tool under Recording mode in web environment > insert menu > checkpoint (from
application)> show the xml pages >click ok > stop Recording.
Note: 1. If XML file is an individual and path available, and then we can go for inserting xml
checkpoint from resource.
Note: 2. If XML file is part of web application, separate path is not available then we can
choose inserting XML checkpoints from application.
9. Page checkpoint:
Navigation:
Keep tool under Recording mode with web environment > Insert menu > checkpoint >
Standard checkpoint >show the web page > click ok > click ok > stop recording.
Navigation:
Keep tool under Recording mode with web environment > Insert menu > checkpoint
>standard checkpoint > show the image > select image > click ok > click ok >stop
recording.
11. Table checkpoint:
Navigation: Keep tool under Recording mode under web environment > Insert menu >
checkpoint > standard checkpoint >show the web table > click ok >stop recording.
Inserting Output values
It is a step in which one or more values are captured during test 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.
Navigation:
Keep tool under Recording mode > Insert menu >output value> standard output value >
show the object > click ok > select property > modify the column name (if required) > click
ok >click ok >stop recording.
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 menu> 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.
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 menu >output value > 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..
4) Database output value:
We can use Database output values to output the value of the contents of database cells.
Navigation:
Insert menu> output value > 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
data cells > click ok > Run and it will capture and see the results in run time table.
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 menu > output
value > XML output value from application > Show the XML document > select elements >
click ok >stop recording.
We can use XML output values to output the values of XML elements in XML documents.
Navigation:
Insert menu >output value> XML output value from resource > browse path of the XML file
> click ok > select elements >click ok.
Parameterization
Data Driven Testing: Testing the Same operation with multiple sets of test data.
1. Through Loop Statements: We can use loop statements for passing sequential numbers & Logical
Numbers.
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.
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
Example: agent=datatable(“agent”,1)
Pass parameters.)
Agent = Datatable("Agent",1)
pwd=Datatable ("Password",1)
Dialog("Login").Activate
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.
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.
1. Creating a Test Database: open MS Access (or we can use any other database).
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.
Note: DSN Creation is one time activity, by using the DSN we can get data for number of tests.
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
Synchronization
It is a process of matching the speeds of both QTP and AUT in order to get proper execution and results.
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.
Note: If we insert wait statements QTP waits up to maximum time even though operation is completed.
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.
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
QTP is providing a Utility object called Services for measuring transaction time
Suppose, we want to measure how much time that one test or part of the test is taking for
execution/running, we can measure using these transaction point (Start and End)
Syntax:
Note: these options (Start and End Transactions) available in QTP tool Insert menu
Example:
services.StartTransaction "Login"
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 "naga"
Dialog("Login").WinEdit("Password:").SetSecure
"4baf50f18b0ae0d5f5425fe760653e96da50bde7"
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Activate
services.EndTransaction "Login"
Note: We can insert number of transaction points in a test
‘Timer’ is a VB Script Built-in function, that can be used for measuring transaction time.
ST=Timer’ It returns elapsed time since 12:00 AM Mid night in seconds
Example:
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 "naga"
Dialog("Login").WinEdit("Password:").SetSecure
"4baf50f18b0ae0d5f5425fe760653e96da50bde7"
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Activate
ET=Timer
TT=ET-ST
msgbox TT
Note: here ST, ET and TT are variables, you can take any variable, I used:
ST for Start Transaction
ET for End transaction
TT for Transaction Time
Step Generator
Step Generator (F7)
Step Generator is a feature of QTP, Library of Functions, used for generating the
Recordable and Non-Recordable steps.
Or
The Step Generator enables us to add steps by selecting from a range of context-sensitive
options and entering the required values. In the Step Generator dialog box we can define
steps that use:
Note: we can use the Step Generator to insert steps in tests and function libraries. Hover, in
function libraries, we cannot use the Step Generator to access test object names or
collections, or to access the list of library functions.
Before we open the Step Generator to define a new step, we first select where in our test
the new step should be inserted.
After we open the Step Generator, we first select the category for the step operation (test
object, Utility object or function) and the required object or the function library. We can
then select the appropriate operation (method, property, or function) and define the
arguments and return values, parameterizing them if required.
The Step Generator then inserts a step with the correct syntax into y test. We can continue
to add further steps at the same location without closing the Step Generator.
We can open the Step Generator from the Keyword View, Expert View, or Active Screen.
Adding Comments
To ensure that the script host does not attempt to interpret a comment as a
command, we must preface each comment with a comment delimiter.
VBScript allows two delimiters: the single quotation mark (') and the REM
statement.
For example, both of the following lines of code are valid comments:
Although most script writers use the single quotation mark, you might consider
following the single quotation mark with an asterisk when commenting your code:
This approach has two advantages over the single quotation mark alone. First, it
makes the comment stand out from the rest of the text; a single quotation mark by
itself can be difficult to see at times.
Second, the single quotation mark is a valid VBScript character that has uses
beyond delimiting comments.
For example, compare the two commenting styles in the following script snippet; in
the first half of the script, comments are placed on the same line as a VBScript
statement, while in the second half of the script, the comments are placed on
separate lines.
Most people find it easier to quickly identify the comments used in the second half
of the script.
-----------------------------------------------
On Error Resume Next
If Err.Number <> 0 Then '* Check to make sure the operation succeeded.
Err.Clear
End If
Err.Clear
End If
-----------------------------------------------
All procedures should begin with a brief comment describing what they do.
This description should not describe the implementation details (how it does it)
because these often change over time, resulting in unnecessary comment
maintenance work, or worse, erroneous comments.
The code itself and any necessary inline comments describe the implementation.
Return values for functions and variables that are changed by a procedure,
especially through reference arguments, should also be described at the beginning
of each procedure.
Section Heading:
Comment Contents:
Purpose:
Assumptions:
Variables, controls, and procedures should be named clearly to ensure that inline
comments are only needed for complex implementation details.
At the beginning of your script, you should include an overview that describes the
script, enumerating objects, procedures, algorithms, dialog boxes, and other
system dependencies. Sometimes a piece of pseudocode describing the algorithm
can be helpful.
Debugging Tests
Debugging Tests
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.
Debug Commands:
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.
Note: After opening the function, if we use step over it executes one statement at a time
only.
3) Step Out (shift +F11):
a=100
b=200
c=a+b
msgbox c
msgbox "hello"
Call hyderabad
Break Point:
Navigation:
Or
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.
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
Navigation: View menu > Debug Viewer > Use step into feature.
Analyzing Test Results & Reporting
Analyzing the Test Result is not a responsibility of QTP. After Running Tests, User (Test
Engineer) has to analyze the test result. and send defect reports.
After Running/Executing a test, then QTP Provide result window. we export test result from
result window in Document (.Doc), HTML, XML and PDF formats.
Note: QTP doen't provide batch wise test result, if we execute test batches. It provides test
wise result only.
a) Pass
b) Fail
c) Done
d) Warning
For defining our own results, QTP is providing an utility object called "Reporter"
Syntax:
Example"
exaplanation:
1) Pass -micPass or 0
2) Fail -micPass or 1
3) Done- micDone or 2
4) Warning- micDone or 3
Reporting Defects
QTP is an Object based Test tool. We can create and execute tests using QTP. QTP Provides,
various methods for crating and enhancing Tests.
After Running Tests, QTP provides result in Result window and also provides a facility to
define our own Results. Result Exporting facility also available in QTP Result window.
Any how Analyzing Results is the Responsibility of Test Engineer after running tests.
If we are using QTP for Functional Test Automation and Defect management manual, then
entering defect details in company prescribed format and sending.
If we are using Bugzilla or Zera or PR-Tracker like Bug Tracking tool, then after analyzing
results, if we find any mismatches sending defects through the Bug tracking tool (Every Bug
Tracking tool has its own defect report template)
If we are using Quality center for Test management, then we can send defects directly from
QTP result window. In between QTP and Quality Center back to back integration is available.
Actions
Purpose of Actions:
For understandability
Types of Actions:
Operations on Actions:
• Creating Actions
• Splitting Actions
• Renaming Actions
• Deleting Actions
• Calling an Action
• Copying an Action
Creating an Action:
Insert>call to new action>enter name of the action>click ok
Steps:
Splitting an action:
Navigation: Place cursor in desired location>Edit menu>action>split action>Enter Action 1 name & action
2 name.
Steps:
Renaming actions:
Select desired action in action drop down box> edit menu>action>rename action>modify the name>click
ok.
Deleting Actions:
Select desired action in action drop down box>edit menu>action>delete action>confirm deletion.
Calling an action:
Insert>call to existing action>browse path of the test>select desired action>click ok.
Copying an action:
Insert>call to copy of action>browse path of the test>select desired action>click ok.
String Functions
1) Left Function
Syntax:
variable=Left(string,Lengh)
Example:
Dim val,x
val="Hyderabad"
x=Left(val,3)
msgbox x ' Output: Hyd
val="9247837478"
x=Left(val,1)
msgbox x ' Output: 9
val="H92yderabad"
x=Left(val,3)
msgbox x ' Output: H92
x=Left(9247837478,5)
msgbox x ' Output: 92478
val=#10-10-10#
x=Left(val,3)
msgbox x ' Output: 10/
2) Right Function
Example:
Dim val,x
val="Hyderabad"
x=Right(val,3)
msgbox x ' Output: bad
val="9247837478"
x=Right(val,1)
msgbox x ' Output: 8
val="H92yderabad"
x=Right(val,3)
msgbox x ' Output: bad
x=Right(9247837478,5)
msgbox x ' Output: 37478
val=#10-10-10#
x=Right(val,5)
msgbox x ' Output: /2010
3) Mid function
Example:
Dim val,x
val="Hyderabad"
x=Mid(Val,5,3)
msgbox x ' Output: rab
val="Hyderabad"
x=Mid(Val,5)
msgbox x ' Output: rabad
val="9247837478"
x=Mid(val,6,5)
msgbox x ' Output: 37478
val="H92yderabad"
x=Mid(val,1)
msgbox x ' Output: H92yderabad
x=Mid(9247837478,5)
msgbox x ' Output: 837478
val=#10-10-10#
x=Mid(val,5)
msgbox x ' Output: 0/2010
4) StrReverse
Example:
Dim val,x
val="Hyderabad"
x=StrReverse(val)
msgbox x 'Output dabaredyH
val="001"
x=StrReverse(val)
msgbox x 'Output: 100
val=1002
x=StrReverse(val)
msgbox x 'Output: 2001
val=#10-10-10#
x=StrReverse(val)
msgbox x 'Output: 0102/01/01
x=StrReverse("Hyderabad")
msgbox x 'Output: dabaredyH
x=StrReverse(100)
msgbox x 'Output: 001
5) StrComp Function
if
Example:
Dim str1,str2,x
str1="India"
str2="India"
x=StrComp(str1,str2,1)
msgbox x 'Output 0
str1="india"
str2="INDIA"
x=StrComp(str1,str2,1)
msgbox x 'Output 0
str1="India"
str2="Indian"
x=StrComp(str1,str2,1)
msgbox x 'Output -1
str1="Indian"
str2="Ndia"
x=StrComp(str1,str2,1)
msgbox x 'Output -1
str1="Indian"
str2="India"
x=StrComp(str1,str2,1)
msgbox x 'Output 1
str1=100
str2=100
x=StrComp(str1,str2,1)
msgbox x 'Output 0
str1=100
str2=101
x=StrComp(str1,str2,1)
msgbox x 'Output -1
6) Lcase function
Dim val,x
val="HYDERABAD"
x=Lcase(val)
msgbox x 'Output hyderabad
val="Hyderabad"
x=Lcase(val)
msgbox x 'Output hyderabad
val="HederabaD"
x=Lcase(val)
msgbox x 'Output hyderabad
val="hyderabad"
x=Lcase(val)
msgbox x 'Output hyderabad
x=Lcase("HYDERABAD")
msgbox x 'Output hyderabad
7) Ucase function
Example:
Dim val,x
val="HYDERABAD"
x=Ucase(val)
msgbox x 'Output HYDERABAD
val="Hyderabad"
x=Ucase(val)
msgbox x 'Output HYDERABAD
val="HederabaD"
x=Ucase(val)
msgbox x 'Output HYDERABAD
val="hyderabad"
x=Ucase(val)
msgbox x 'Output HYDERABAD
x=Ucase("HYDERABAD")
msgbox x 'Output HYDERABAD
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.
Syntax:
Variable = Environment(“environment variable name”)
Ex:
X=Environment (“ActionName”)
Msgbox x
Example Script:
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.
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
X=environment (“city”)
Msgbox x
It is a way of representing data using symbols. They are often used within matching,
searching or replacing algorithms.
Regular expressions can be used in QTP for identifying objects and text strings with varying
values.
Where we use:
We can define a regular expression for a constant value, a Data Table parameter value, an
Environment parameter value, or a property value in Descriptive programming.
We can define a regular expression in standard checkpoint to verify the property values of
an object; we can set the expected value of an object's property as a regular expression so
that an object with a varying value can be verified.
We can define the text string as a regular expression, when creating a text checkpoint to
check that a varying text string is displayed on our application,
For XML checkpoints we can set attribute or element values as regular expressions.
A backslash (\) can serve two purposes. It can be used in conjunction with a special
character to indicate that the next character be treated as a literal character.
Alternatively, if the backslash (\) is used in conjunction with some characters that would
otherwise be treated as literal characters, such as the letters n, t, w, or d, the combination
indicates a special character.
A period (.) instructs QTP to search for any single character (except for \n).
Ex:
welcome.
Matches welcomes, welcomed, or welcome followed by a space or any other single
character.
Square brackets instruct QTP to search for any single character within a list of characters.
Ex:
To search for the date 1867, 1868, or 1869, enter:
186[789]
When a caret (^) is the first character inside square brackets, it instructs QTP to match any
character in the list except for the ones specified in the string.
Example:
[^ab]
Matches any character except a or b.
To match a single character within a range, we can use square brackets ([ ]) with the
hyphen (-) character.
Example:
For matching any year in the 2010s, enter:
201[0-9]
An asterisk (*) instructs QTP to match zero or more occurrences of the preceding
character.
For example:
ca*r
A question mark (?) instructs QTP to match zero or one occurrences of the preceding
character.
For example:
ca?r
Matches car and cr, but nothing else.
Parentheses (()) instruct QTP to treat the contained sequence as a unit, just as in
mathematics and programming languages. Using groups is especially useful for delimiting
the argument(s) to an alternation operator ( | ) or a repetition operator ( * , + , ? , { } ).
A caret (^) instructs QTP to match the expression only at the start of a line, or after a
newline character.
A dollar sign ($) instructs QTP to match the expression only at the end of a line, or before a
newline character.
\w instructs QTP to match any alphanumeric character and the underscore (A-Z, a-z, 0-9,
_).
\W instructs QTP to match any character other than alphanumeric characters and
underscores.
We can combine regular expression operators in a single expression to achieve the exact
search criteria we need.
For example,
start.*
Matches start, started, starting, starter, and so forth.
we can use a combination of brackets and an asterisk to limit the search to a combination of
non-numeric characters.
For example:
[a-zA-Z]*
To match any number between 0 and 1200, we need to match numbers with 1 digit, 2
digits, 3 digits, or 4 digits between 1000-1200.
The regular expression below matches any number between 0 and 1200.
([0-9]?[0-9]?[0-9]|1[01][0-9][0-9]|1200)
RegExp object
VB Script is providing RegExp object for defining Regular expressions, It provides simple
support for defining regular expressions.
Regular Expression Object Properties and Methods:
Properties:
a) Global Property
b) IgnoreCase Property
c) Pattern Property
Methods:
a) Execute Method
b) Replace Method
c) Test Method
Virtual Object Configuration is a process of making the QTP to treat a specified area
or a user defined object as Virtual Object.
Virtual objects enable us to create and run tests on objects that are not normally
recognized by QTP.
We can manage the virtual objects defined on our computer using the Virtual
Object Manager.
Navigation:
Click Next
Mark the area in the Application with help of mark object button
Click next
o Parent only
Click on Next
Click finish
Virtual object Manager feature enable us to create and manage Virtual Objects
Batch Testing
Executing a group of Tests or series of tests at a time is known as Batch Testing or Batch
Execution. For performing Batch Testing, QTP is providing a separate Tool called Test Batch
Runner.
Note: Test Batch Runner launches QTP Tool, QTP runs Tests one by one.
Open Test Batch Runner >open Test Batch>Select or deselect tests>run test batch.
Recovery Scenarios
To recover from unexpected events and errors that are occurred in the test environment
during run session, we can use Recovery Scenario Manager. For good recovery, error must
be known the occurrence is unknown.
Navigation:
Resources Menu -> Recovery Scenario Manager-> Click New- > Click Next - >
Select Application Crash as Trigger event->Next - >Select selected executable
application->Next ->Select Recovery Operation [Keyboard, Mouse Operation,
Close Application Process, function Call, Restart, Microsoft Windows] ->Next - >If
you want to check Add another operation else uncheck->Next - >Next - >Enter
Scenario Name ->Next- >Select Option - >Finish - >Close - >Save the scenario in
specified location with “.qrs”
(qrs stands for QuickTest Recovery Scenario.)
Navigation:
A step in your test does not run successfully then Test Run Error
can be raised.
Navigation :
Navigation:
Resources Menu -> Recovery Scenario Manager -> New -> Next -> Select “Object state
Window” as Trigger event -> Next -> Click on Hand Icon -> Show object with hand icon
-> Next -> Next->select object property with value (enabled ,false)->click next -> Select
function call as Recovery
Operation -> Next [Open Notepad -> Save empty file with .vbs extension] -> Browse
the .vbs fie path -> Next -> Uncheck Add another Recovery Operation -> Next ->
Select Post-Recovery Test Run Option [Repeat current step and continue, Proceed to
Next step, Proceed to Next Action, Proceed to next test iteration, Restart current test
run, Stop the Test Run] -> Next-> Enter Scenario Name -> Next -> Select Option ->
Finish -> Save the scenario with “.qrs” -> Record required Recovery Operation [Click
ok, Click Cancel] take the script into function -> Save the library file -> Click Run
File System Operations
File System:
The File System Object (FSO) model provides an object-based tool for working with folders
and files. It allows us to use the familiar object.method syntax with a rich set of properties,
methods, and events to process folders and files. We can also employ the traditional Visual
Basic statements and commands.
The FSO model gives our application the ability to create, alter, move, and delete folders, or
to determine if and where particular folders exist. It also enables us to get information
about folders, such as their names and the date they were created or last modified.
The FSO model makes processing files much easier as well. When processing files, our
primary goal is to store data in an efficient, easy-to-access format. We need to be able to
create files, insert and change the data, and output (read) the data. Although we can store
data in a database, doing so adds a significant amount of overhead to our application. We
may not want to have such overhead, or our data access requirements may not call for the
extra functionality associated with a full-featured database. In this case, storing our data in
a text file or binary file is the most efficient solution.
The FSO model, contained in the Scripting type library (Scrrun.dll), supports the creation
and manipulation of text files through the TextStream object; however, the FSO model does
not support binary files. To manipulate binary files, use the FileOpen Function with the
Binary keyword.
Examples:
1) Create a folder
Set fso=createobject("scripting.filesystemobject")
fso.CreateFolder(strFolder)
2) Create a folder
Set fso=createobject("scripting.filesystemobject")
If fso.FolderExists(strFolder) Then
msgbox "Folder already exists"
else
fso.CreateFolder(strFolder)
End If
3) Data Driven Testing by fetching Test data directly from a Text file.
'*********************************************************
'Test Requirement: Data Driven Testing by Fetching Test data directly from a Text file.
'Author: G C Reddy
'Pre-requisites:
'vinod.txt (Test Data)
'Test Flow:
'Creating an Automation Object in FileSystem class
'Opening the External Test Data file using the Object
'Read the Data & Split the Data
'Generating the Login Operation
'Pass Parameters
'********************************************************
Do Until myFile.AtEndOfStream
myLine=myFile.ReadLine
myField=Split(myLine,",")
SystemUtil.Run "C:\Program Files\HP\QuickTest
Professional\samples\flight\app\flight4a.exe"
Dialog("text:=Login").Activate
Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set myField(0)
Dialog("text:=Login").WinEdit("attached text:=Password:").Set myField(1)
wait 2
Dialog("text:=Login").WinButton("text:=OK").Click
Window("text:=Flight Reservation").Close
Loop
myFile.Close
Set objFso=Nothing
Option Explicit
Dim objFSO, objFolder, strDirectory
strDirectory = "D:\Gcreddy"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder(strDirectory)
2) Delete a Folder
3) Copying Folders
Set oFSO=createobject("Scripting.Filesystemobject")
oFSO.CopyFolder "E:\gcr", "C:\jvr", True
4) Checking weather the folder available or not, if not creating the folder
Option Explicit
Dim objFSO, objFolder, strDirectory
strDirectory = "D:\Gcreddy"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strDirectory) Then
Set objFolder = objFSO.GetFolder(strDirectory)
msgbox strDirectory & " already created "
else
Set objFolder = objFSO.CreateFolder(strDirectory)
end if
2) Checking weather the File is available or not, if not creating the File
strDirectory="E:\"
strFile="Gcreddy.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strDirectory & strFile) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFile = objFSO.CreateTextFile("E:\Gcreddy.txt")
End if
5) Reading data from a flat file and using in data driven testing
Dim fso,myfile
Set fso=createobject("scripting.filesystemobject")
Set myfile= fso.opentextfile ("F:\Gcreddy.txt",1)
myfile.skipline
While myfile.atendofline <> True
x=myfile.readline
s=split (x, ",")
Set objFSO=createobject("Scripting.filesystemobject")
Set txtFilepath = objFSO.GetFile("E:\gcr.txt")
txtFilepath.Delete()
8) Checking weather the File is available or not, if available delete the File
strDirectory="E:\"
strFile="gcr.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strDirectory & strFile) Then
Set objFile = objFSO.Getfile(strDirectory & strFile)
objFile.delete ()
End if
Dim f1, f2
f1="e:\Gcreddy1.txt"
f2="e:\Gcreddy2.txt"
Public Function CompareFiles (FilePath1, FilePath2)
Dim FS, File1, File2
Set FS = CreateObject("Scripting.FileSystemObject")
If FS.GetFile(FilePath1).Size <> FS.GetFile(FilePath2).Size Then
CompareFiles = True
Exit Function
End If
Set File1 = FS.GetFile(FilePath1).OpenAsTextStream(1, 0)
Set File2 = FS.GetFile(FilePath2).OpenAsTextStream(1, 0)
CompareFiles = False
Do While File1.AtEndOfStream = False
Str1 = File1.Read
Str2 = File2.Read
CompareFiles = StrComp(Str1, Str2, 0)
If CompareFiles <> 0 Then
CompareFiles = True
Exit Do
End If
Loop
File1.Close()
File2.Close()
End Function
Call Comparefiles(f1,f2)
If CompareFiles(f1, f2) = False Then
MsgBox "Files are identical."
Else
MsgBox "Files are different."
End If
sFileName="E:\gcr.txt"
sString="gcreddy"
Const FOR_READING = 1
Dim oFso, oTxtFile, sReadTxt, oRegEx, oMatches
Set oFso = CreateObject("Scripting.FileSystemObject")
Set oTxtFile = oFso.OpenTextFile(sFileName, FOR_READING)
sReadTxt = oTxtFile.ReadAll
Set oRegEx = New RegExp
oRegEx.Pattern = sString
oRegEx.IgnoreCase = bIgnoreCase
oRegEx.Global = True
Set oMatches = oRegEx.Execute(sReadTxt)
MatchesFound = oMatches.Count
Set oTxtFile = Nothing : Set oFso = Nothing : Set oRegEx = Nothing
msgbox MatchesFound
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdText = &H0001
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
strPathtoTextFile = "C:\Databases\"
Do Until objRecordset.EOF
Wscript.Echo "Name: " & objRecordset.Fields.Item("Name")
Wscript.Echo "Department: " & _
objRecordset.Fields.Item("Department")
Wscript.Echo "Extension: " & objRecordset.Fields.Item("Extension")
objRecordset.MoveNext
Loop
Const ForReading = 1
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
arrServiceList = Split(strNextLine , ",")
Wscript.Echo "Server name: " & arrServiceList(0)
For i = 1 to Ubound(arrServiceList)
Wscript.Echo "Service: " & arrServiceList(i)
Next
Loop
'Test Flow:
'Login Operation
'Open Order Operation and form the Loop to open 1 to 10 Orders
'Capture Cusomer names using GetROProperty Method
'Create File system Object and Open the Text file using the Object and Export Cusomer
names
'----------------------------------------------------------------------------
Option Explicit
Dim Order_Number, Customer_Name, objFso, myFile
Set objFso=CreateObject("Scripting.FileSystemObject")
Set myFile= objFso.CreateTextFile ("C:\Documents and Settings\1
RIGHATWAY\Desktop\abcNew.txt",2)
myFile.WriteLine "Cusomer Names"
myFile.WriteLine "--------------------"
If Not Window("Flight Reservation").Exist(3) Then
SystemUtil.Run "C:\Program Files\HP\QuickTest
Professional\samples\flight\app\flight4a.exe","","C:\Program Files\HP\QuickTest
Professional\samples\flight\app\","open"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "asdf"
Dialog("Login").WinEdit("Password:").SetSecure
"4c48590870466b8dc050bbd24e816890c747ccf8"
Dialog("Login").WinButton("OK").Click
End If
For Order_Number= 1 to 10 step 1
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 Order_Number
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Customer_Name = Window("Flight Reservation").WinEdit("Name:").GetROProperty("text")
wait (2)
myFile.WriteLine Customer_Name
Next
myFile.Close
Set objFso=Nothing
Database connections
Database connections
Database connection is a facility in computer science that allows client software to communicate with
database server software, whether on the same machine or not.
Standard Security:
"Driver={SQLServer};Server=Your_Server_Name;Database=Your_Database_Name;Uid=Your_Usernam
e;Pwd=Your_Password;"
Trusted connection:
"Driver={SQLServer};Server=Your_Server_Name;Database=Your_Database_Name;Trusted_Connection
=yes;"
SQL OLE DB connection strings
Standard Security:
Trusted connection:
"Provider=SQLOLEDB;Data Source=Your_Server_Name;Initial
Catalog=Your_Database_Name;Integrated Security=SSPI;"
SQL OleDbConnection .NET strings
Standard Security:
"Provider=SQLOLEDB;Data Source=Your_Server_Name;Initial Catalog=
Your_Database_Name;UserId=Your_Username;Password=Your_Password;"
Trusted connection:
"Provider=SQLOLEDB;Data Source=Your_Server_Name;Initial
Catalog=Your_Database_Name;Integrated Security=SSPI;"
SQL SqlConnection .NET strings
Standard Security:
1. "Data Source=Your_Server_Name;Initial Catalog=
Your_Database_Name;UserId=Your_Username;Password=Your_Password;" < br>2.
"Server=Your_Server_Name;Database=Your_Database_Name;UserID=Your_Username;Password=Your
_Password;Trusted_Connection=False"
Trusted connection:
1. "Data Source=Your_Server_Name;Initial Catalog=Your_Database_Name;Integrated Security=SSPI;"
2."Server=Your_Server_Name;Database=Your_Database_Name;Trusted_Connection=True;"
Workgroup:
"Driver={Microsoft Access Driver (*.mdb)}; Dbq=C:\App1\Your_Database_Name.mdb;
SystemDB=C:\App1\Your_Database_Name.mdw;"
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.
Example:
option explicit
Dim qtApp,qtTest
Set qtApp=createobject ("Quicktest.Application")
qtApp.Launch
qtApp.visible=True
qtApp.quit
Loading repositories during running, finding path of the repositories and removing
repositories is called Dynamic Handling of Object Repositories.
Using this feature we can increase QTP performance. To do this, QTP is providing an object
called “RepositoriesCollection”.