0% found this document useful (0 votes)
39 views

Part - 1: A Quick Revision of HP QTP 10.0 An Advanced Solution To Functional & Regression Test Automation

The document provides an overview of QuickTest Professional (QTP) 10.0, an automated testing tool. It discusses QTP's life cycle including test planning, generating tests, enhancing tests, debugging tests, executing tests, and analyzing results. It also covers recording scripts in different modes, playing back scripts in different modes, managing the application under test, parameterization, and the object repository. The document is intended to provide a quick introduction and revision to key concepts and features in QTP 10.0.

Uploaded by

softwaretester4u
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Part - 1: A Quick Revision of HP QTP 10.0 An Advanced Solution To Functional & Regression Test Automation

The document provides an overview of QuickTest Professional (QTP) 10.0, an automated testing tool. It discusses QTP's life cycle including test planning, generating tests, enhancing tests, debugging tests, executing tests, and analyzing results. It also covers recording scripts in different modes, playing back scripts in different modes, managing the application under test, parameterization, and the object repository. The document is intended to provide a quick introduction and revision to key concepts and features in QTP 10.0.

Uploaded by

softwaretester4u
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 76

A Quick Revision of HP QTP 10.

An Advanced Solution to

Functional & Regression Test Automation

Part - 1

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Topics Covered in Part - 1
 Brief Introduction to QTP 10.0
 Quick overview of QTP Life Cycle
 Keyword Driven Testing Approach
 Which test cases to be automated
 Key Elements of QTP
 Recording of Scripts
 Playback of Scripts
 Managing Application Under Test
 Parameterization
 Object Repository
 Object Properties & Functions
 Data Driven Testing Approach
 Managing External Excel sheets

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Introduction to QuickTest Professional 10.0
What is QuickTest Professional10.0?

 QuickTest Professional 10.0 is a next-generation automated testing tool from HP,


which uses the concept of keyword-driven testing to enhance the test creation and
maintenance.

 It is a Functional and Regression testing tool, which can record the user actions,
keyed in while recording and execute these user actions while we play back the test.

 QuickTest Professional meets the needs of both technical and non-technical users.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Quick Overview of QTP Life Cycle
1) Test planning
2) Generating the basic test
3) Enhancing the test
4) Debugging the test
5) Executing the test
6) Analyzing the results.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


QTP Life Cycle - Test Planning
Automation test lead carries out the activities like:

1) Understanding the requirements


2) Identifying the areas to be automated
3) Analyzing positive as well as negative flow of these areas
4) Preparation of automation test plan document based upon the above
analysis
5) Preparations for the tool being ready with all pre configuration settings
for further operations

QTP Life Cycle - Generating the Basic Test


Automation test engineers generate the basis test for positive as well
as negative flow of the test

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


QTP Life Cycle - Enhancing the Test
Tests can be enhanced by the following:

1) Inserting the checkpoints


2) Synchronizing the test
3) Parameterizing the test (Data Driven Testing)
4) Inserting the output values
5) Measuring transactions
6) Inserting programmatic statements
7) Inserting comments
8) Inserting the script statement manually

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


QTP Life Cycle - Debugging the Test
It is a process of executing the script in a user desired fashion with an objective of identifying the errors.

For debugging QTP offers features like

3 - Step Commands:

1) Step Into
2) Step Out
3) Step Over

1 - Break Point: For breaking the execution temporarily

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


QTP Life Cycle - Executing the Test
In this phase testers execute the Test

QTP Life Cycle - Analyzing the Test


In this phase testers do the analysis of the Results

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Keyword Driven Testing Approach
 Keyword-driven testing is a technique which differentiates most of the
programming effort from the actual steps in testing so that these steps
can be developed earlier and can be maintained with only minor
updates, even when the application undergoes significant changes.

 With this approach, testing engineers are able to make full utilization
of test and object properties, through an integrated scripting and
debugging environment fully synchronized with the Table Based
Keyword View or in the VBScript-based Expert View.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Identification of test cases to be automated
 When we have a large number of test cases, we have to carefully
analyze them and group them into categories and then decide if that
test case should executed on every release/build of the application or
not.

 If the test case is not intended to be executed on every release it


should not be automated since it falls into a one-time" testing
category.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Identification of test cases to be automated
 Some test cases might be very time consuming to automate where as
executing them manually could be just a matter of 5 to 10 minutes.
 Such type of test cases should be given the least priority in terms of
when to automate them. Some test cases may have manual intervention
for example: when we create an account in the application someone in
our team has to run some batch processes manually in order for us to
continue with further testing.
 These kind of test cases should not be automated unless we have full
control of the backend processes to be run for successful completion of
the test using QTP.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Key Elements of QTP
QTP has two main components:

a) VB Script Language

b) Object Repositories

While recording the user actions on the applications QTP will generate the VB Script
statements, which indicate the actions it is supposed to perform. While recording, QTP will
also learn the objects present in the application, say for example a Window, check box,
radio button etc., and stores these objects in a place called Object Repository.

In order to run the test successfully the corresponding object should exist in the Object
Repository.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Recording of Scripts
Different modes of Recording in QTP

There are three modes

 Context Sensitive Mode

 Low Level Mode

 Analog Mode.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Recording Modes in QTP
Context Sensitive Mode:
In this mode QTP records the objects and properties of the objects from the
application so that it can identify them while playing back the script.

99% of testing is done with the help of context sensitive mode.

Analog mode:
This mode is used for recording the continuous operations.

In this mode QTP records the mouse movements and key strokes on the keyboard
as Tracks so that it can help us in testing the situations like signature scanning or
handwriting or drawing some objects on the screen or in a window etc.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Recording Modes in QTP

Low Level Recording Mode:

It is a special mode available in QTP that is used for recording the minimum operations on the
Non-Supported environments as well.

In this mode QTP records the objects based on their location by capturing the X and Y coordinates
of the objects on the screen.

The Analog and Low Level recording modes can be selected only after hitting the record button. In
the picture below the First icon is for Analog recording and the second one is for Low Level
recording.

Analog and Low Level Recording modes can only be selected after starting to Record and
going to the Automation menu.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Playback of QTP Scripts
Different Modes of Executing Tests in QTP

There are three modes of replaying the test. These are not listed on the tool bar.

When we hit the “Run” button we get the "Run" dialogue box, which gives us two options.

1) To save the results in New run results folder. This is the Verify mode.

2) To save the results in Temporary run results folder overwriting the


earlier results. This is the Debug mode.

3) When we need to run the test to update the Checkpoints go to


Automation" menu and select "Update Run Mode".

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Playback of QTP Scripts
Verify Mode: If the test engineer wants to save the results of the test run to compare
and verify with the future runs of the same test he would go with the verify mode.

Debug Mode: If the Test engineer does not want to save the results as he is yet to
finish the script or he is testing his QTP coding logic he would run the test in the
debug mode.

Update Mode: If a test engineer wants to update the expected results while running
the test, say for example while recording the script the calendar date was 10/20/2008
and while executing the test it is a different date (system date), then the test should
be run in the update mode otherwise the test would fail because of the changed
properties of the object.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Activities During QTP Script’s Play Back
1) QTP's inbuilt interpreter checks for the syntax errors in the script.

2) It checks to see if the object specified in the script exists in the repository.

3) It checks if the object specified in the script exists on the Application


Under Test.

4) Does the action / task specified in the script.

During script execution if any of the above phases encounter the error, then an
error window pops up depending on the situation.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Error Messages During Script Play Back
Syntax Error

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Error Messages During Script Play Back
Object not found in the repository

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Error Messages During Script Play Back
Objects exists in the repository but is not displayed on the screen

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Managing Application Under Test

How to start the Application Under Test?

If we are working with just one application

If we are working with multiple applications

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Working with just one application
 In QTP we can specify the URL for the application or the exe file of the
application within the settings. Go to "Automation" menu and select
"Record and Run Settings" option. It opens a Record and Run settings
dialogue box, which has options to enter the URL of the application for
web or exe file of the application if it is windows application.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Working with just one application
 For the main test, which calls the reusable actions, we can use the option "Open the following browser when a record or run session
begins".

Once the application is open we don't need to open the application again so for all the reusable action we can use the option "Record and
run test on any open Web browses".

But we should make sure that all the browsers except Quality Center are closed before recording or running the tests.

For windows applications we can select the application by clicking the "Add" button and browsing the 0065xecutable file of the application.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Working with just one application

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Working with Multiple applications
 At workplace usually we will be working with more than one application and we might need to automate the test cases for these applications.

In this situation we should select the Radio button "Record and run test on any windows based application" for non web based application or "record and run test on any open browsers" for web applications which will instruct QTP not to open any application by itself.

Then we need to include the statement SysternUtil.Run in the Login script /Action and execute that as the first action in the flow of actions.

Example: SystemUtil.Run www.softwaretestinggenius.com

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Working with Multiple applications
Or if it is a windows based application we have to give the path of the executable.
SystemUtil.Run "C..\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe''

What statement would we use to send the results to the test results? We would use Reporter. Reportevent followed by the step name, description and result to send the result to the test results and get the status whether the step passed or failed.

Example:
Reporter. ReportEvent 0,"Property Check", "Property Checked Passed”

Value "0" indicates that the step is passed and "1" indicates that the step is failed. We can also use micPass or micFail in place of 0 or 1.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Parameterization
What is Parameterization
It is a process by which we can expand the scope of our basic test by replacing fixed values with
parameters. This process, greatly increases the power and flexibility of our tests.

In other words it is a way of data entry into the application without hard coding the values within the
test script.

We have following ways to parameterize


 Using values from Data Table

 Using Environment Variables

 Using Random Numbers generated

 Using Test Parameters

 Using Action Parameters

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Parameterization
Manual Parameterization

In order to avoid the several navigation steps we can directly do manual


parameterization

For Example:

A = data table (“V1”,1)


Vbwindow (“form1”). Vbedit (“val1”). Set a.
Vbwindow (“form1”). Vbedit (“val2”). Set data table (“v2”, 1)
Vbwindow (“form1”). Vbbutton (“Add”). Click

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Parameterization
What are the standard Object classes?

 Developers assign properties to each object on the application.

 Object class is an industry standard to identify a particular type of object


in the application and some of the commonly used standard classes are:

1) Window 6) Checkbox
2) Dialog box 7) Radio button
3) Menu 8) List box
4) Push button 9) Combo box
5) Edit Box

If the class property of the object is defined as Object or WinObject or WebElement


depending on the type of application you are using, then it is not a standard object
and comes under the category of Non-Standard object.
>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<
Parameterization
How to identify an object if it is not associated with any standard
class?

Any object which is not associated with the standard class will have a
class of either Win Object (for Windows applications) or Web Element
(for web applications) and are considered as Non-Standard objects.

Non-standard objects are represented with a special Tri-colored


symbol in the Object Repository.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Parameterization
How to identify an object if it is not associated with any standard
class?

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Object Repository
What is an Object Repository?

Object Repository (OR) is a collection of objects pertaining to the


application under test. Example: All the text boxes. list boxes, images
etc are stored in a file in QTP.

This file is called the object repository.

Each object will have the set of properties to identify that object
uniquely in the application.

At the time of execution, QTP identifies the objects on the screen by


comparing them with the objects and their properties in the repository.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Types of Object Repositories in QTP

QTP has two types of Object Repositories.

1. Action Local repository

2. Shared Object Repository

We can have any number of Shared Object Repositories associated


with an action. All the objects will be recorded into the local repository
and we need to export the objects from local repository into the shared
object repository by opening the object repository and selecting File
Menu and selecting "Export Local Objects".

You need to specify the name for the shared object repository in which
you want to save these objects.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Types of Object Repositories in QTP

How to Associate multiple Object repositories for a test?

1) Open the object repository of the action and click on the icon Associate
Repositories on the tool bar.

2) Associate repositories window opens.

3) Click on the green "+" sign and browse the shared object repository and
select it.

All the actions which are available in that script will be shown in the
Available Actions section of that window

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Types of Object Repositories in QTP

How to Associate multiple Object repositories for a test?

4) Select the action which we want to associate the repositories to and click
on the ">" arrow to send it to the "Associated Actions" section of the
window

This will ensure that the actions in the associated actions will have access to
all the objects in the associated object repositories.

We can associate any number of object repositories.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Types of Object Repositories in QTP

How to Associate multiple Object repositories for a test?

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Different Object Repositories Modes
Differentiation between Following two modes:

1) Object Repository Per Action Mode &

2) Shared Object Repository Mode.

Local Object Repository Mode


In this mode there is no need to save the Object repository.

It is automatically loaded with the script and saved into the script folder.

The effort to maintain Object Repository is relatively less, but if we have


a lot of tests we get confused with the Object Repositories and when a
change is made in application it has to be modified in all the Object
Repositories.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Object Properties

What are Object Properties?

Most Objects will have two types of properties defined within the application.

1) Identification Properties

2) Native Properties

The properties defined for the object in the application can be discovered
by using the object spy icon which is on the toolbar or from "Tools”
menu select Object Spy.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Identification Properties

What are Identification Properties?

These are the properties which an object attains based on the condition
within the application.

Example: The FLIGHT button is designed to have a runtime/Identification


property of enabled=False when we open the Flight reservation window
and once we select the Date and fly from and fly to this objects runtime
property is designed to change the enabled=True.

These are dynamic values which can keep changing.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Native Properties

What are Native Properties?

These are the properties defined within the


application for each object which will act as
base properties and they may not change
dynamically.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Functions in QTP

What is a function?

Function is a program which takes in the arguments or parameters


and does the steps specified in the program and ultimately gives us
an output.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Functions in QTP

Function verify Button Status(ButtonName ,ExpectedStatus)


AclualStatus= wlndow("Flight Reservation") WinButton(ButtonName)
GetROProperty("enabled')
If Actuastatus= ExpectedStatus Then

Reporter.ReportEvent micpass,'Verify Flight Button' "Flight button was


disabled as expected"

else
Reporter.ReportEvent micFail,"Verify Flight Button "Flight button was
enabled but the expected was disabled"
End If
End Function
Function Call: VerifyButtonStatus "FLIGHT",False

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Functions in QTP

Return Value
A function should return a value in most of the cases. This return value
can be used in the script where the function is being called for various
reasons.

A return value should be returning either a variable from the function or


value calculated in the function or any value string which we specify within
the function such as "Pass" or "Fail". To return a return value give the
function name = Value to be returned.

For example:
If the return value given by Login function is "Pass" or "True" we may
want to continue further testing else we may want to end the test if it
returns a value of "Fail" or "False".

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Functions in QTP

Return Value continued

var FIightLogin = FlightLogin(”piyush", "mercury") If var FIightLogin, =


"Pass" Then
RunAction "OrderEntry [OrderEntry]", alliterations
RunAction "FlightLogout [FlightLogout]", onelteration
else
ExitActionlteration()
End If

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Functions in QTP

Storage of Functions in separate function libraries

QTP functions can be written and stored in a VB Script file which has an
extension of vbs (plain text file stored with an extension of vbs) and we
can attach that file in the "File” "Settings" “Resources” and
under resources we have the top most section which says "Associated
library files".

Click on the "+" sign in that section and browse the VB Script file which
has the functions you created.

For example: 'Function to close all browsers before starting the test
execution can be given as:

call CIoseAllBrowsers() or simply CIoseAllBrowsers()


>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<
Functions in QTP

Storage of Functions

All the functions should be stored in a common function library.

Open a blank notepad file.

Paste all the functions in that and save that file with an extension vbs and
with a name which can identify it as a function library
(For example: FlightFunctionLibrary).

Save this file under a new folder called "Function Libraries" in the
project folder.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Functions in QTP

What is VBS? VBS stands for Visual Basic Script.


Once you save the library go to QTP and select Settings from the File
menu. Test Settings window appears. Go to Resources Tab. We will see
a section called Function Libraries.

Click on the Green "+" sign in that and browse your function library which
we saved in the project folder.

Now all the functions present in that library will be available to all the
scripts with this settings.

We can save any number of functions in one vbs file but for maintenance
purposes it is better to limit the number to 50 functions or build a separate
function library for each module within the application if these modules are
large modules.
>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<
Functions in QTP

Where ever we need to call a function press F7 and the Step generator
window will open.

From the top drop down, select Functions and then from the second drop
down, select library functions.

Now we will be able to see a list of all the functions present in all the
libraries which you attached to that script.

Select the function which we need to use, give the arguments and press
Insert button.

The function call will be inserted in our script at the cursor position.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Few Examples of Functions

Function to Return the Maximum Number of Days in a Month

Function NoOfDaysInMonth(InMonth)
Dim NoOfDays
Select Case InMonth
Case "01", "1", "03", "3", "05", "5", "07", "7", "08", "8", "10", "12”
NoOfDaysinMonth ="31"
Case "02", "2”
NoOfDaysInMonth = "28"
Case "04", "4", "06", "6", "09", "9", "07", "11"
NoOfDaysinMonth = "30"
Case Else
NoOfDayslnMonth = "The value passed is an illegal parameter"
End Select
End Function
>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<
Few Examples of Functions

Function to Change the Date according to Parameters

Function ChangeDate(dttochange mm, be, yyyy)


Dim DateArray, NewDate
If mm = ""Then
mm = 0
End If ,
If dd = ""Then
dd =0
End If
If yyyy = ""Then yyyy = 0
End If

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Few Examples of Functions

Function to Change the Date according to Parameters Contd.

NewDate = DateAdd("m", mm,dttochange)


NewDate = DateAdd("d",do NewDate)
NewDate= DateAdd("yyyy",yyyy,NewDate)
DateArray = Split(NewDate, "/")
Mth = DateArray(0)
Dt = DateArray(1)
Yr = DateArray(2)
If Mth<10 Then
Mth = "0"&Mth
End If

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Few Examples of Functions

Function to Change the Date according to Parameters

If Dt<10 Then
Dt = "0" &Dt
End If
NewDate = Mth&"/"&Dt&"/"&Yr
ChangeDate = NewDate
End Function

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Few Examples of Functions
Function to Close all Browsers except the Test Director & QC

Function CIoseAllBrowsers()
Dim vcol Handles, vCtr, vHwnd, Flag, vLastHWnd
vCtr = 0
Flag = 1
Set vcol Handles=CreateObject("ScriptingDlctlonary'")
While (Window("regexpwndclass:=lEFrame","Index:=" & vCtr).Exist And
Flag)
wait 1
vHwnd= Window("regexpwndclass:=lEFrame","index=" &
vCtr).getroproperty("Hwnd") If (vLastHWnd=vHwnd) Then
Flag = 0
Else
vcol Handles.Add CStr(vcol Handles.Count),vHwnd
vCtr = vCtr+1
>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<
Few Examples of Functions
Function to Close all Browsers except the Test Director & QC Contd.

End If
vLastHWnd = vHwnd
Wend

'Use reverse order in this for loop so that the text and Hwnd remain in correct
order after each one is closed ForvCtr=vcol_Handles .Count-1 to 0 step -1
Walt 1

vHwnd=vcol Handles.ltem(CStr(vCtr))
vBrowser=Window("regexpwndclass:=lEFrame","index .=" &
vCtr).getroproperty("text")

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Few Examples of Functions
Function to Close all Browsers except the Test Director & QC

If Instr(vBrowser, "TestDirector") or Instr(vBrowser, "Quality Center") then


Reporter.ReportEvent 2, "Not closed " & vBrowser, "The browser "' &
vBrowser & "' was not closed"
Else
Reporter ReportEvent 2, "Closed " & vBrowser, "The browser "' & vBrowser
& "' was closed" Window("hwnd:=" & vHwnd) Close
End If
Next
End Function

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Few Examples of Functions
Function to Check the Screen Name

Function ScreenCheck(ScreenName)
Rc= Browser("Browser ).Page("Page").
WebElement(ScreenName).GetROProperty("innertext")
If Rc = ScreenName Then
Reporter.ReportEvent micpass,"screen check', ScreenName&" screen
appeared"
ScreenCheck = "Pass"
Else
Reporter.ReportEvent micfall, "screen check", ScreenName&" screen did not
appear"

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Few Examples of Functions
Function to Check the Screen Name Contd.

ScreenCheck = "Fail"
ExitGIoballteration() 'Goes to next row in the Globs! Table (or next test
case).
End If
End Function

Example. Screen Check("Restrictions") ` Where "Restrictions' is the name of


the screen.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Mapping a custom class to a standard class
Custom object is an object which is not recognized by QTP and it is recorded
as WinObject, but if we think it can be used as a standard object such as
edit field or radio button we can map it to that standard class.

Select “Tools” “Object Identification”. In the Object Identification


dialogue box select “Standard windows” in the Environment box.

The user-defined box will now be enabled. Click “User Defined”. The object
mapping dialogue box opens.

Click the hand icon and click on the object whose class we want to add to
user-defined class.

In the Map to box select the standard object class to which we want to map
this user-defined object.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Ways to Split a Date
How to split a date, described is in the "mm/dd/yyyy” format

DateArray = Split(Date, 'Y")


MyDate = Datearray(0)&' -"& Datearray(1)&' ="&Datearray(2)
MsgBox MyDate
Date gives the today's date.

In this "/" is the delimiter. DateArray will store the values which can be used
as displayed by MsgBox and concatenated together as a single variable
MyDate as shown above.

MsgBox is for displaying the variable value. We need to delete or


comment all the lines with MsgBox once we are done fixing our script.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Data Driven Testing in QTP
What is Data Driven Testing?

It is a concept introduced in automation to implement Re-Testing.

In other words Data Driven Testing is a process of entering the variable


values into the application taking them from the data sheet.

Typical Steps involved in Data Driven Testing are:

1) Collection of the data in to the data table


2) Generation of the Basic test
3) Execution of the Test
4) Analyzing the Results

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Data Driven Testing in QTP
Process of Data Driven Testing

Variable values can be passed into QTP through the Global sheet or local
sheet depending on the architecture you are using.

Easiest way to parameterize the data is through the Keyword view.

Parameterization of data through the Keyword view

From the keyword view select the object whose value you want to pass
through the data table.

Click in the Value column for that row and you will see a little <#> sign in the
right hand corner of that cell.

Click on that and Value Configuration Options window will open.


>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<
Data Driven Testing in QTP
Parameterization of data through the Keyword view Contd.

This will have two main radio buttons “Constant” and “Parameter”.

We can see the current value present in the Constant edit field.

Select the “Parameter” radio button.

Select “DataTable” from the drop down next to parameter.

(We can also select the other two options present in the drop down
Environment or the Random Number).

Now enter the field name from which we want to select the data. In case this
particular field doesn't exist QTP will create the one for us.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Data Driven Testing in QTP

Parameterization of
data through the
Keyword view

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Data Driven Testing in QTP
Parameterization of data through the Keyword view contd.

Then select from which data table you want to enter the data.

We can enter the data either from the Global sheet or from the Current action
sheet (local table).

Now click "OK". The field will be created for us and the data for that field is
taken from the data table instead of having a hard coded value within the
script.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Writing Data to the Data tables
Output Value feature

This feature is used for capturing a value from an application or from a


database or from a XML file and storing it under a specified column in
the run time data table during the execution

We have following 5 types of output values:

1) Standard output value


2) Text output value
3) Text area output value
4) Database output value
5) XML output value

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Writing Data to the Data tables
We can write the data grabbed into the variables. This is done during the
recording mode.

Start the record session and from the "Insert" menu select "Output Value"
and based on the type of object we need to select either “Standard Output
value” or the “Text output value”.

For example if the object is a list item or edit box select “Standard Output
value” . QTP will then show the object properties and now we need to select
what property we want to output. In this case it is the "Value".

Also we need to specify the field name into which we want to send the value
and the data table whether Global sheet or local sheet.

QTP will suggest us a field name we can either accept or change according
to our naming conventions.
>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<
Writing Data to the Data tables

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Writing Data to the Data tables
If the Text desired to be captured is the one displayed by the application on
the screen, use the "Text Output Value" and point the text, which we want
to capture and define an appropriate field name and table.

This output value is shown only in the runtime and once the test execution is
finished the data can't be seen in the data table.

But we can see the data in the Runtime data table in the results.

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Writing Data to the Data tables

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Sending the variable values to the Data table
The variable values can be passed to the local or global tables
programmatically.

If the varPolicyNumber is the variable which holds the policy number which
needs to be sent to the data table we can send that value into local sheet
using the following statements into the Policy-Number column in the local
sheet of the action.

varPolicyNumber = 123456”

DataTable("Policy Number'',dtLocalSheet) = varPolicyNumber

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Managing External Excel sheets
To manage data in the external excel file:

We need to define the automation objects to work with an external excel file.

Set ExcelObj = CreateObject("Excel.Application")

The above line creates an Excel object ExcelObj which has reference to
open excel file.

ExcelObj.Workbooks.Open "C'.\Data\OutPut.xls”

Above statement opens the excel file "C:\Data\OutPut.xls" in the background

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Managing External Excel sheets
To manage data in the external excel file:

Set NewSheet = Excel Obj.Sheets. Item("MyOutputSheet")

The above statement creates a sheet called "MyOutputSheet"

NewSheet.Cells(2,1) = VariableName

The above statement will populate the value present in the VariableName
variable to the second row and first column of the sheet "MyOutputSheet".

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Managing External Excel sheets
To open an excel sheet in the background and delete the rows 2 to 21

Set ExcelObj = Create Object("Excel.Application'')


ExcelObj. Workbooks. Open("C: \Deletetest.xls'')
For i=1 to 20
ExcelObj. Rows("2:21 '). Select
ExcelObj. Selection. Delete
Next
ExcelObj.ActiveWorkbook.Save
ExcelObj.Application. Quit
Set ExcelObj = Nothing

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Managing External Excel sheets
To Delete the rows from external Excel sheet by the name “DeleteSheet”

Set ExcelObj = Create Object ('Excel. Application')


ExcelObj.Workbooks. Open("C: \Deletetest.xls'')
For i=1 to 20
ExcelObj.Sheets("DeleteSheet''). Rows("2:20''). Select
ExcelObj.Selection. Delete
Next
ExcelObj.ActiveWorkbookSave
ExcelObj. Application. Quit
Set ExcelObj = Nothing

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<


Thank You

End of Part -1

Quick Revision of HP QTP 10.0

>>>>>>>>>>>>>>>>>>>>>> www.softwaretestinggenius.com <<<<<<<<<<<<<<<<<<<<<<

You might also like