Regular Expressions in QTP
Regular Expressions in QTP
Regular expressions can be used in QTP for identifying objects and text
strings with varying values.
Where we use:
a) Backslash 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]
201[0-9]
A plus sign (+) instructs QTP to match one or more occurrences of the
preceding character.
For example:
ca+r
Matches car and caaaaaar, but not cr.
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.
Descriptive Programming
Entering / Providing objects information directly into the test script is
called Descriptive Programming.
Advantages:
b) Scripts are portable (we can run these scripts from any machine
easily)
QTP Commands
QTP Commands are available in 3 ways.
1.Menu options
2.Tool Bar options
3.Short cut keys (for Some important operations only)
File menu: Through file menu user can create, save tests, open
existing tests, export tests in zip format.
Command Function
New > Test Creates a new test.
New > Business Creates a new business component.
Component
New > Scripted Creates a new scripted component.
Component
New > Application Area Creates a new application area.
New > Function Library Creates a new function library.
Open > Test Opens an existing test.
Open > Business/Scripted Opens an existing business or scripted
Component component.
Open > Application Area Opens an existing application area.
Open > Function Library Opens an existing function library.
Close Closes the active function library.
Close All Function Closes all open function libraries.
Libraries
Quality Center Connection Opens the Quality Center Connection dialog
box, enabling you to connect to a
Command Function
Undo Reverses the last command or deletes the last entry
you typed.
Redo Reverses the most recent operation of the Undo
command.
Cut Removes the selection from your document.
Copy Copies the selection from your document.
Paste Pastes the selection to your document.
Delete Deletes the selection from your document.
Copy Documentation to Copies the content of the Documentation column of
Clipboard the Keyword View, enabling you to paste it in an
external application.
Action > Split Action Separates an action into two sibling actions or into
parent-child nested actions.
Action > Rename Action Changes the name of an action.
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 Properties Enables you to specify options, parameters, and
associated object repositories for a stored action.
Action > Action Call Enables you to specify the number of run iterations
Properties 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 a
Comment Properties comment step. Available only when the selected step
is a comment.
Step Properties > Object Opens the Object Properties dialog box for a
Properties selected object. Available only when the selected
step contains a test object.
Step Properties > Opens the relevant Checkpoint Properties dialog box
Checkpoint Properties for a selected object. Available only when the
selected step is a checkpoint step.
Step Properties > Output Opens the relevant Output Value Properties dialog
Value Properties box for a selected object. Available only when the
selected step is an output value step.
Step Properties > Report Displays the Report Properties dialog box for a
Properties report step. Available only when the selected step is
a Reporter.ReportEvent step.
Find Searches for a specified string.
Replace Searches and replaces a specified string.
Go To Moves the cursor to a particular line in the test.
Bookmarks Creates bookmarks in your script for easy
navigation.
Advanced > Comment Comments out the current row, or selected rows.
Block
Advanced > Uncomment Removes the comment formatting from the current
Block or selected rows.
Advanced > Indent Indents the step according to the tab spacing defined
in the Editor Options dialog box.
Advanced > Outdent Outdents the step (reduces the indentation)
according to the tab spacing defined in the Editor
Options dialog box.
Advanced > Go to Navigates to the definition of the selected function.
Function Definition
Advanced > Complete Completes the word when you type the beginning of
Word a VBScript method or object.
Advanced > Argument Displays the syntax of a method.
Info
Advanced > Apply "With" Generates With statements for the action displayed
to Script in the Expert View, and enables IntelliSense within
With statements.
Advanced > Remove Converts any With statements in the action
"With" Statements displayed in the Expert View to regular (single-line)
VBScript statements.
Optional Step Inserts an optional step (a step that is not required to
successfully complete a run session).
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.
Run Starts a run session from the beginning or from
the line at which the session was paused.
Stop Stops the recording or run session.
Run Current Action Runs only the active action.
Run from Step Starts a run session from the selected step.
Maintenance Run Mode Starts a run session during which the
Maintenance Run Mode wizard opens for steps
that failed because an object was not found in
the application (if applicable).
Update Run Mode Starts a run session to update test object
descriptions and other options (if applicable).
Analog Recording Starts recording in Analog Recording mode.
Low Level Recording Starts recording in Low Level Recording
mode.
Record and Run Settings Opens the Record and Run Settings dialog box,
enabling you to define browser preferences for
recording and running your test.
Process Guidance List Lists the processes that are available for the
current document type and for the currently
loaded QuickTest add-ins, enabling you to open
them.
Results Enables you to view results for a test run
session.
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.
Command Function
Object Repository Opens the Object Repository window, which
displays a tree containing all objects in the current
test or component.
Object Repository Manager Opens the Object Repository Manager dialog box,
enabling you to open and modify multiple shared
object repositories.
Associate Repositories Opens the Associate Repositories dialog box,
enabling you to manage the object repository
associations for the test.
Map Repository Parameters Opens the Map Repository Parameters dialog box,
enabling you to map repository parameters, as
needed.
Recovery Scenario Manager Opens the Recovery Scenario Manager dialog box.
Associated Function Libraries Lists the function libraries associated with the
active document, enabling you to open them.
Debug Menu:
This menu provides debug commands for step by step execution.
Through this menu we can insert/remove/break points.
Tools Menu:
This menu provides Tools settings option, view options and object
identification configuration.
Through this menu we can set tool options as well as test pane view
options.
In this menu object spy option available, through this we can get
object’s information.(Properties and values)
In this menu Virtual object option available; through this option we
can create virtual objects.
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.
Check Syntax Checks the syntax of the active document.
Object Identification Opens the Object Identification dialog box, enabling you to
specify how QuickTest identifies a particular test object.
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.
Web Event Recording Opens the Web Event Recording Configuration dialog box,
Configuration enabling you to specify a recording configuration level.
(Relevant for tests only)
Data Driver Opens the Data Driver dialog box, which displays the default
Constants list for the action. (Relevant for tests only)
Change Active Screen Replaces the previously recorded Active Screen with the
selected Active Screen. (Relevant for tests only)
Virtual Objects > New Opens the Virtual Object Wizard, enabling you to teach
Virtual Object QuickTest to recognize an area of your application as a
standard test object.
Virtual Objects > Virtual Opens the Virtual object Manager, enabling you to manage all
Object Manager of the virtual object collections defined on your computer.
Customize Opens the Customize dialog box, which enables you to
customize toolbars and menus, and create new menus.
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.
Passing parameters, through this we can pass multiple values.
Data Driven Testing: Testing the Same operation with multiple sets
of test data.
Through Data Table: QTP adds one data table (Spreadsheet) for every test, we can use
Data Table for Data Driven Testing.
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