QTP Presentation

100
QTP PRESENTATION

Transcript of QTP Presentation

Page 1: QTP Presentation

QTP PRESENTATION

Page 2: QTP Presentation

SESSION OBJECTIVES Introduction to Automation Benefits of Automated Testing Automated Testing Process Introduction to QTP and its Salient Features Environment Supported

Page 3: QTP Presentation

WHAT IS AUTOMATION A software program that is used to test

another software program, this is referred to as Automated software testing.

Test Automation is the use of software to control the execution of tests & the comparison of results- actual with the predicted/expected.

A third party tool is used to test the application.

Use of automation tools reduces the test time as well as the cost

Page 4: QTP Presentation

WHY AUTOMATION Avoid the errors that human make when they

get tired after multiple repetitions. The test program wont skip any test by

mistakes. Each feature test cycle will take less time &

Required less human intervention. Required for Easy cycle of Regression Testing.

Page 5: QTP Presentation

BENEFITS OF TEST AUTOMATION Allows more testing to be done. Strengthen Test Cycle. Testing is Consistent, repeatable. Fast, Reliable, Repeatable, Programmable,

Comprehensive, Reusable.

Page 6: QTP Presentation

FALSE BENEFITS Fewer tests will be needed It will be easier if it is automated Compensate for poor design No more Manual Testing

Page 7: QTP Presentation

WHICH TEST CASES TO AUTOMATE? Tests that need to be run for every build of

the application (sanity check, regression test) Tests that use multiple data values for the

same actions (data driven tests)

Page 8: QTP Presentation

WHICH TEST CASES NOT TO AUTOMATE? Usability testing

"How easy is the application to use?" One-time testing "ASAP" testing

"We need to test NOW!" Ad hoc/random testing

based on intuition and knowledge of application

Page 9: QTP Presentation

WHAT ARE THE DIFFERENT TOOLS AVAILABLE IN THE MARKET (FOR FUNCTIONAL TESTING)

Rational Robot Win Runner QTP Silk Test QA Run Web FT

Page 10: QTP Presentation

VERSION HISTORY OF QUICKTEST PROFESSIONAL Astra QuickTest (Mother tool of QTP) 1.0 to 5.0

Quick Test Professional 5.6 – Nov 2002 6.5 – 2003 8.0 – 2004 8.2, 8.3 –2005 9.0,9.1-2006 9.2- 2007 Mercury Interactive 9.5 –2008 H.P 10.00 –2009 January

Page 11: QTP Presentation

BASIC FEATURES OF QTP

QTP Launched in 2002 (Nov). By Mercury Interactive. Later taken over by HP, in 2007.

QTP is an Object Based Testing Tool.(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)

QTP is for Functional and Regression Testing. (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.

(Keyword Driven Approach means; Keywords example Commands, functions, methods, statements etc.. are used for creating Test scripts)

It supports Windows Operating Environment only.(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.

Page 12: QTP Presentation

OTHER SALIENT FEATURES QTP can automatically introduce Checkpoints During execution testers can manually insert

several types of check points to verify that the objects continue to behave as expected.

Testers are able to record their tests so that each action, or step in the business process are modular & reusable.

When application under test changes, testers can update Object Repository, thus the change made is then propagated across all the scripts that reference to this object

EX: In the Authentication screen when the name of the button is changed to Sign In form Login, Just make an update in the Object Repository.

Page 13: QTP Presentation

CONTD…. After running a test QTP displays the results

in a tree structure and in clear visual reports Scripting Language is VBScript which is easy

to use , understand and program even complex functionalities with ease.

Library files contains VBScript functions and subroutines that can be added to the test.

Page 14: QTP Presentation

ADD-IN MANAGER

Page 15: QTP Presentation

ADD-INS Default

ActiveX Visual Basic Web

Additional Java Oracle PeopleSoft .NET Terminal Emulator Sap, Siebel & Web services

Page 16: QTP Presentation

WHAT TYPE OF TOOL IS QTP Record and playback tool It has additional features like sync pt, check pt,

output values It has– Built in functions It has – User defined functions , Registered

functions.

Page 17: QTP Presentation

ENVIRONMENTS SUPPORTED Browsers

Netscape Internet Explorer AOL

Operating Systems Windows XP/2003 Windows 2000 Windows 98 Windows NT Windows ME

Page 18: QTP Presentation

TYPES OF VIEWS IN TEST PANE Two types Keyword view – Actions are generated in

tabular format similar to manual test cases Expert view – Actions are generated in VB

scripting

Page 19: QTP Presentation

KEYWORD VIEW

Page 20: QTP Presentation

EXPERT VIEW

Page 21: QTP Presentation

QUICKTEST TESTING PROCESS The Quick Test testing process consists of 7

main phases: Preparing to record Recording a session on your application Enhancing your test Debugging your test Running your test Analyzing the test results Reporting defects

Page 22: QTP Presentation

RECORD USER ACTIONS

Page 23: QTP Presentation

START RECORDING ON ANY WEB SITE. CHOOSE TEST > RECORD OR CLICK THE RECORD BUTTON. THE RECORD AND RUN SETTINGS

DIALOG BOX

Page 24: QTP Presentation

SAVE THE TEST The test can be saved into a Windows file system (as below). If TestDirector is available and connected with QTP, the test can be

saved there. QTP creates an entire structure of files and directories to support a

single QuickTest script for each saved test.

Page 25: QTP Presentation

VERIFY SUCCESSFUL PLAYBACK Use the ‘Run’ button to begin playback from the top of the test. Select the location of the test results- either a new results folder

or a temporary folder.

Page 26: QTP Presentation

VIEWING THE TEST RESULTS Test results can be stored in their own location (for documentation) or in a

temporary location that is overwritten each time the test is run (debugging).

Page 27: QTP Presentation

MODES OF RECORDING Normal mode – recording based on

properties of GUI Analog mode – mouse movements,

clicks, keyboard strokes Low level – records any object irrespective

of support from QTP. Recognizes all run time objects as windows objects. It is used when an object is not identified by Quick test and co-ordinates based.

Page 28: QTP Presentation

RUNNING A SESSION The Run option can be used to run the test from start to end. The Run from Step option in the Test menu is used to run the

test from a selected step to the end of the current action, if running from the Expert View, or to the end of the test , if running from the Keyword View. Thus it enables us to check a specific part of the application or to confirm that a certain part of the test runs correctly.

Page 29: QTP Presentation

HOW QUICKTEST WORKS WITH OBJECTSWhat are Object Properties?

A set of characteristics that defines an object’s appearance, values, state and identity in an application.

QTP captures these object properties during recording. Logical Name – Logical name is a value QuickTest

usually takes from one of the object properties (like TEXT) to refer to the object in the recorded script.

Page 30: QTP Presentation

OBJECT REPOSITORY Object Repository is nothing but a storage

location. It contains the collection logical name and physical description of a particular object.

Object Repository is a location within the test structure where QuickTest stores object information captured during recording.The Object Repository can be used to:

Rename logical names for readability. Add a new object in the repository. Configure the object properties used to identify an object.

While playback of scripts, qtp refers object repository for identifying the objects

Page 31: QTP Presentation

OBJECT REPOSITORY Two types – Per action, Shared

Repository The Object Repository can be Per Action or

Shared. The shared repository can be used by

multiple actions of the same test or by actions from different tests. Test object properties are prone to frequent updation.

Per Action object repository is used by one or very few tests. Test object properties are modified less frequently.

Page 32: QTP Presentation

OBJECT REPOSITORY

Page 33: QTP Presentation

OBJECT RECOGNITION Mandatory properties – QTP always learns for

differentiating objects Assistive properties – optional properties

learnt when mandatory couldn’t able to differentiate

Page 34: QTP Presentation

OBJECT RECOGNITION Ordinal Identifier – This is used when

both mandatory and assistive couldn’t help to differentiate objects

Ordinal identifier uses location indicator and index indicator to differentiate objects

Page 35: QTP Presentation

OBJECT IDENTIFICATION Object identification is another

component in QTP. This is used to configure the

mandatory and assistive properties depending on application to be tested.

Page 36: QTP Presentation

OBJECT IDENTIFICATION

Page 37: QTP Presentation

WHAT ARE TYPES OF PROPERTIES? Test object – Properties learnt by QTP while

recording that is used for mapping with actual objects

Runtime – Properties of actual object in the application

Page 38: QTP Presentation

OBJECT SPY Object spy is a component in QTP that

helps to list the test object and runtime properties of the GUI

Lists the methods and syntax that could be implemented on that particular object

Lists the hierarchy of the object in the AUT

Page 39: QTP Presentation
Page 40: QTP Presentation

CHECKPOINTS IN QTP A checkpoint is a verification point that compares a

current value for a specified property with the expected value for that property.

Page 41: QTP Presentation

TYPES OF CHECKPOINTS Standard Checkpoint Bitmap checkpoint Text checkpoint Text Area checkpoint Database checkpoint XML Checkpoint

Page 42: QTP Presentation

TYPES AND THEIR USE Standard Checkpoint

Bitmap Checkpoint

Checks the property value of the object in an application or Webpage. It checks buttons,Radiobuttons,Comboboxes etc

Checks the value of an image in the application.

Page 43: QTP Presentation

Text Checkpoint

Checks whether the text string is displayed in the appropriate place in your application or on a Web page

Page 44: QTP Presentation

Database Checkpoint

XML Checkpoint

Checks the contents of a database accessed by the application

Checks the data content of XML documents in the application.

Page 45: QTP Presentation

WHEN TO USE CHECKPOINTS Before creating checkpoints on web objects

we have to select web-test option in ADD-IN Manager.

If the objects developed in HTML we can use Standard Check point.

If the Objects developed in XML we can use XML Check point.

Page 46: QTP Presentation

HOW CHECKPOINTS WORK - PLAYBACK

Script Expected Result

Execute checkpointObject: ButtonLogical Name : OKProperty: EnabledValue: True

Actual = expected ?

Test ResultsPASS

Page 47: QTP Presentation

SAMPLE OBJECTS THAT QUICKTEST CAN VERIFY

WINDOWS WEBWindow BrowserEdit Field Text AreaDrop down list Text LinkMenu command ImagesRadio Button Image LinkCheckbox Edit FieldWindows Object Drop down listStatus Bar CheckboxText Area Radio Button

Tables/ GridsWeb Element

Page 48: QTP Presentation

HOW TO ADD A CHECKPOINT1.Select the object in the Active

Screen2.Right Click on it and Select

‘Insert Standard Checkpoint’ or

Menu Insert Checkpoint Standard Checkpoint

Page 49: QTP Presentation

HOW TO ADD A CHECKPOINT… SET EXPECTED VALUE

» Do not automatically select the pre-defined list of properties to check.

» Scroll down the property list to find the property( or properties) that best meets the test requirement.

Page 50: QTP Presentation

TABLE CHECKPOINT

Page 51: QTP Presentation
Page 52: QTP Presentation

DATABASE CHECKPOINT Choose Insert > Checkpoint > Database

Checkpoint. The Database Query Wizard opens.

Page 53: QTP Presentation

DATABASE CHECKPOINT ..CONTD

Page 54: QTP Presentation
Page 55: QTP Presentation

HOW TO ADD A CHECKPOINT… TEST RESULT

Page 56: QTP Presentation

OUTPUT VALUES Outputs the value of properties of

GUIduring runtime Can be viewed in runtime data table in

results window Mainly used to get collection of

property value of dynamic objects

Page 57: QTP Presentation

PARAMETRIZATION Parameterization - Passing multiple set of

values for testing A parameter is a variable that is assigned a

value from an external data source at run time. We use parameterization when we want to change the value of properties at run time.

Page 58: QTP Presentation

HOW CAN WE PARAMETRIZE? Identify the fixed value that needs to be

parametrized Replace with parameter Passing value from data table

Page 59: QTP Presentation

WHAT IS DATA TABLE Inbuilt XL sheet in QTP for passing

values to parameters in runtime Two sheets – global and action Global – Data is passed to all actions

within the script Action – Data is passed to only

particular action

Page 60: QTP Presentation

WAYS TO PARAMETRIZE.. Data table parameter – Passing

through data table Action/component parameter – By

declaring input and output parameter in action properties

Environment parameter – External host, url, vuser etc…

Page 61: QTP Presentation

DATATABLE PARAMETERS The Test runs once for each line of data in

the DataTable. Each iteration takes a different value from the datatable.

choose the Run tab Test

Settings

Specify an option in the Datatable iterations frame.

Page 62: QTP Presentation

ENVIRONMENT VARIABLE PARAMETERS The Environment variables can have Quick

Test generated values or values supplied from external files.

Test Settings

Environment

Choose User-defined from the variable type

Click New to create your own internal variables

Page 63: QTP Presentation

RANDOM NUMBER PARAMETERS It enables us to use random numbers as

values in the test. We can specify the range from which the random number is generated. By default, the random number range is between 0 and 100.

Page 64: QTP Presentation

HOW TO PARAMETERIZE AN INPUT VALUE

» Select the step in the Tree View that contains the recorded input value.

» Click on the text under Value column.

Page 65: QTP Presentation

HOW TO PARAMETERIZE AN INPUT VALUE… CONTD.

-Select the source for paramterization.

-Select the parameter name.

-Select the data sheet to use.

Page 66: QTP Presentation

HOW TO PARAMETERIZE AN INPUT VALUE…CONTD

Page 67: QTP Presentation

ACTIONS A test is composed of actions or logical

sections. The steps we add to the test are added within the test’s actions. By default, each test begins with a single action.

When we run a test with multiple actions, the Test Results are divided by actions so that we can view the detailed results for each action individually.

Each action has its own sheet in the Data Table so that we can insert data that applies only to that action.

Page 68: QTP Presentation

TYPES OF ACTIONS Non-re-usable: Action can be used in the

local test, only once. Reusable: Action can be used in the local

test, multiple times. External: These are reusable actions created

in another test. This can be of two types. If a call to an external action is used the action is read only in the calling test. But, any existing action can be inserted as a copy of the original action. In this case, we can modify this copy of the external action in the calling test.

Page 69: QTP Presentation

CALLING ACTION INSERT CALL TO EXISITING ACTION –

CALLS A REUSABLE ACTION, BUT ANY CHANGES WILL BE REFLECTED ON ORIGINAL CALLED ACTION

INSERT CALL TO COPY OF ACTION – CALLS A REUSABLE ACTION, BUT CHANGES ARE NOT REFLECTED ON ORIGINAL CALLED ACTION

Page 70: QTP Presentation

HOW TO SET AN ACTION AS REUSABLE

Page 71: QTP Presentation

HOW TO CALL A REUSABLE ACTION

Insert Call to existing Action

Page 72: QTP Presentation

TRANSACTIONS TRANSACTIONS ARE NOTHING BUT

TIMER FOR MEASURING TIME TAKEN FOR EXECUTING PARTICULAR TASK

SERVICES.START TRANSACTION “T1” SERVICES.END TRANSACTION “T1” CAN BE USED ANY NUMBER OF TIMES

Page 73: QTP Presentation

DEBUGGING DEBUGGING – FINDING ERRORS IN THE

SCRIPT BREAKPOINTS – POINT WE CREATE IN THE

SCRIPT WHERE THE EXCUTION OF SCRIPT IS PAUSED

WATCHLIST – MAINLY FOR BETTER DEBUGGING. USED TO VIEW THE VALUES OF THE PARAMETERS/VARIABLES DURING RUNTIME

Page 74: QTP Presentation

HOW TO HANDLE CUSTOM OBJECTS??? SOLUTION IS VIRTUAL OBJECT WIZARD THIS HELPS TO MAP THE CUSTOM OBJECT

WITH THE STANDARD GUIS. HENCE WHILE RECORDING QTP RECOGNIZES EVEN THESE NON STANDARD OBJECTS

Page 75: QTP Presentation

HANDLE THE CHANGING WINDOWS/ OBJECT PROPERTIES?? THE SOLUTION IS “REGULAR EXPRESSION” REGULAR EXPRESSION IS AN EXPRESSION

THAT MAKES QTP TO RECOGNIZE THE OBJECTS THAT HAVE VARYING PROPERTY DURING RUNTIME

Page 76: QTP Presentation

REGULAR EXPRESSION \ – SYMBOL TO INDICATE IT IS AN

REGULAR EXPRESSION . – PERIOD MATCHES ONE

CHARACTER !WELCOME. CAN MATCH WELCOMES, WELCOMED

* - MATCHES ANY NUMBER OF CHARACTER !W*-WHO, WE

[] – TO INDICATE COLLECTION LIKE !W[E3] – WE, W3

Page 77: QTP Presentation

REGULAR EXPRESSIONS - INDICATES RANGE LIKE [0-9] ^ INDICATES EXCLUSION LIKE [^A-Z]

WILL NOT ACCEPT UPPER CASE ALPHABETS

+ indicates one or more occurrence of preceding character ca+r – car, caaar and not cr

\w matches all characters except alphanumeric and underscore

Page 78: QTP Presentation

WHAT ARE EXCEPTIONS??? EXCEPTIONS ARE NOTHING BUT

UNEXPECTED ERRORS THAT CAUSES HINDERANCE DURING THE EXECUTION OF SCRIPTS

COULD BE DUE TO POP UPS, OBJECT PROPERTY CHANGE, APPLICATION CRASH, TEST RUN

Page 79: QTP Presentation

HOW TO HANDLE EXCEPTION??? SIMPLE USING RECOVERY SCENARIO

MANAGER. RECOVERY SCENARIO MANAGER IS A WIZARD

THAT GUIDES STEPS TO HANDLE EXCEPTIONS

Page 80: QTP Presentation

RECOVERY SCENARIO MANAGER THREE STEPS TRIGGER EVENT – DEFINE THE EXCEPTION RECOVERY OPERATION – DEFINING THE

HANDLER FUNCTION POST RECOVERY OPERATION.

Page 81: QTP Presentation

FUNCTION? PROCEDURE??? FUNCTION CAN BE INBUILT OR USER

DEFINED. IT IS ONE THAT RETURNS A VALUE PROCEDURE IS SIMILAR TO FUNCTION BUT

DOESN’T RETURN VALUE

Page 82: QTP Presentation

SOME IMPORTANT FUNCTIONS - SETTOPROPERTY SETTOPROPERTY() PROPERTYNAME, VALUE DIALOG(“Login”).WinEdit(“Username”).SETTOP

ROPERTY(“Enabled”,”True”)

Page 83: QTP Presentation

GETTOPROPERTY() GetTOProperty( propertyname) Returns the value of the property Example, A =

Dialog(“Login”).Winbutton(“OK”).GetTOProperty(“Enabled”)

Page 84: QTP Presentation

GETTOPROPERTIES( ) GetTOProperties() Lists all the properties and property values of

particular object

Page 85: QTP Presentation

GETROPROPERTY() GetROProperty(Propertyname) Returns the runtime property of the

particular object Dim a A =

dialog(“login”).Winbutton(“OK”).GETROPROPERTY(“nativeclass”)

Page 86: QTP Presentation

CAN WE CONNECT DATABASE THROUGH QTP??? Answer is yes not through wizard but

through scripting Set a =

createobject(“ADODB.connection”) A.open”DSN = Employee.mdb,

Username = xxx, Password = xxxx” Set b =

createobject(“ADODB.RecordSet”) B.open”Select * from table1”,a Msgbox b.recordcount

Page 87: QTP Presentation

FILE HANDLING Using QTP it is possible to pass datas from

various files and write data into file Example to read data from a file Set a =

createobject(“Scripting.FileSystemObject”) Set b = a.opentextfile(“path”,0/1/8,”true”) Str = b.readline 0 – write mode 1- read mode 8 – append True/false – file exist or create new

Page 88: QTP Presentation

CHILDOBJECTS() This function is used to return the list of all

objects within the window Example to count no of objects within dialog Set c = dialog(“Login”).childobjects() Msgbox c.count

Page 89: QTP Presentation

POPUP() POPUP(“MSG”,WAIT TIME, “TITLE”,BUTTON) EXAMPLE SET A = POPUP(“HI”,10,”GREETING”,4) A WILL BE RETUNED VALUE 6(YES) AND

7(NO)

Page 90: QTP Presentation

MAXIMIZE WINDOW MAXIMIZE IS KEYWORD FOR MAXIMIZING

WINDOW/DIALOG FULLSCREEN IS THE KEYWORD FOR

MAXIMIZING THE BROWSER

Page 91: QTP Presentation

DATATYPE CONVERSION CINT() – CONVERTS VAR TO INTEGER CLNG() – CONVERTS CURRENCY TO INTEGER CCUR()- CONVERTS TO CURRENCY FORMAT

Page 92: QTP Presentation

IS IT POSSIBLE TO OPEN APPLICATION THROUGH SCRIPTING??? YES!!!

SYSTEMUTIL.RUN “PATH” FOR OPENING ANY APPLN

INVOKE “PATH” FOR EXE APPLICATION EXECUTE “PATH”

Page 93: QTP Presentation

USER DEFINED FUNCTION FUNCTIONS THAT ARE REPEATED FOR MANY TIMES EXAMPLE PUBLIC FUNCTION SUM(X, Y, Z) Z = X+Y END FUNCTION DIM A, B, C A = INPUTBOX (“ENTER A”) B = INPUTBOX(“ENTER B”) SUM (A,B,C) MSGBOX C

Page 94: QTP Presentation

FRAMEWORKS FRAMEWORKS ARE SET OF DEFINED RULES

FOR AUTOMATING A TESTING PROCESS IT COULD BE SAID AS AUTOMATION TEST

APPROACH

Page 95: QTP Presentation

FRAMEWORKS LINEAR FRAMEWORK – RECORDING,

ENHANCEMENT , PLAYBACK HERE U CREATE SCENARIOS, DO

RECORDING BASED ON SCENARIOS, ENHANCEMENT IS DONE FOR VERIFICATIONS, AND PLAYBACK FOR EXECUTION

Page 96: QTP Presentation

FRAMEWORK DATA DRIVEN – HERE AN EXTERNAL

DATABASE IS MAINTANINED FOR PASSING VALUES TO THE ACTIONS IN QTP

VALUES ARE COMPLETELY PASSED ONLY THRO THIS DATA SETS

Page 97: QTP Presentation

FRAMEWORK KEYWORD DRIVEN – USING THE MANULLY

ENTERED TABLE THAT DEFINES TESTOBJECT, OPERATION, DATA AND DESCRIPTION, VB SCRIPTS ARE AUTOMATICALLY GENERATED BY QTP

Page 98: QTP Presentation

FRAMEWORK DESCRIPTIVE PROGRAMMING – IT IS A

CONCEPT OF EXECUTION OF SCRIPTS WITHOUT THE REFERENCE OF OBJECT REPOSITORY

DIALOG(“CLASS = DIALOG”,”CAPTION = Login”).Winbutton(“class = Button”,”Text = OK”).Click

Page 99: QTP Presentation

FRAMEWORKS FUNCTIONAL/MODULAR – HERE THE ACTIONS

ARE DECLARED AS USER DEFINED FUNCTIONS

THESE FUNCTIONS ARE CALLED WHEREVER NEEDED.

Page 100: QTP Presentation

FRAMEWORK HYBRID FRAMEWORK – MIX OF ANY OF THE

ABOVE FRAME WORKS ARE CLASSED AS HYBRID.

DEPENDING ON COMPLEXITY OF THE APPLICATION, MIXES ARE CHOSEN.