qtp-ppt

Upload: mahi-vey

Post on 31-Oct-2015

61 views

Category:

Documents


0 download

DESCRIPTION

QTP Doc

TRANSCRIPT

  • QTP

    Dhananjay Singh

    Dhananjay Singh

  • *Dhananjay Singh*Life Cycle Of Automation- Analyze the Application

    Select The ToolIdentify the session

    Design/ Record Test ScriptsRun the test scriptsFinding & Reporting the defects

    Dhananjay Singh

  • *Dhananjay Singh*Introduction to QTP -. Developed by Mercury interactive But Now by HP. Developed for web functionality.QTP supports both web applications & windows applications. QTP Developed in 2002. Test Script developed on VB Script. QTP supports Languages is .NET. J2EE, Main Frame, XML,Java ERP -> SAP, Seibel, People soft. QTP Supports both Technical & Non Technical People. QTP run on only windows platform not supporting UNIX, Linux etc

    Dhananjay Singh

  • *Dhananjay Singh*Overview of QTP -Testing Process of QTPWindows Structure of QTPAdd Ins of QTPArchitecture of QTPExecution process in QTPDevelopment of Automation TestRecording Modes in QTPObject RepositoryObject SpyTransactionVirtual ObjectCheck PointsActionsException HandlingObject identificationOrdinal IdentifierSmart IdentificationOutput ValuesSynchronization pointQTP Run ModesRegular ExpressionsDescriptive ProgrammingEnvironment VariablesVB-ScriptHoe to work with FunctionsAssociated Library

    Dhananjay Singh

  • *Dhananjay Singh*Testing Process of QTP - 1) Record & Run Settings 2) Develop Automation Testing 3) Enhance/ Customize Automation test 4) Debug Automation Test 5) Execute Automation Test 6) Analyze Test Results 7) Report defects in bug tracking tool

    Dhananjay Singh

  • *Dhananjay Singh*Window Structure of QTP -1) Test Pane2) Active Screen3) Data Table4) Debug Viewer

    Dhananjay Singh

  • *Dhananjay Singh*Add Ins of QTP -It gives information about the technology supported by the QTPBy default three Add Ins are there in QTP1) ActiveX2) VB3) WebAdditional Add ins: 1) Java 2) Oracle 3) People soft4) .NET5) Terminal Emulator6) SAP7) Siebel

    Dhananjay Singh

  • *Dhananjay Singh*Add In Manager

    Dhananjay Singh

  • *Dhananjay Singh*Architecture Of QTP -Execution Process in QTPDevelopment of Automation TestRecordingWritingFunction Generator

    Dhananjay Singh

  • *Dhananjay Singh*Recording Modes of QTP -There are three recording modes in QTP -

    1)Normal Recording Mode 2) Analog Recording Mode 3) Low Level Recording Mode

    Dhananjay Singh

  • *Dhananjay Singh*Record a Test

    Dhananjay Singh

  • *Dhananjay Singh*Record & Run Settings-

    Dhananjay Singh

  • *Dhananjay Singh*Run a Test and Save Results-

    Dhananjay Singh

  • *Dhananjay Singh*View Test Results-

    Dhananjay Singh

  • *Dhananjay Singh*Object Repository-Object Repository is nothing but a storage location. It contains the collection logical name and physical description of a particular object.

    Logical Name: For Naming ConventionPhysical Description : is Nothing but expected physical propertiesTwo types of Object Repositories are available in QTP-

    1) Per Action (.mtr)2) Shared Object Repository (.tsr)

    Dhananjay Singh

  • *Dhananjay Singh*Open the Object Repository Dialog Box-

    Dhananjay Singh

  • *Dhananjay Singh*Object Spy- Object spy is used to display or view all the physical properties and methods of an object or a window based on the requirement.

    Example: If window(Login). Exists Then Msgbox(Pass) else Msgbox(Fail) End If

    Dhananjay Singh

  • *Dhananjay Singh*Virtual Object-Virtual Object is used to identify the properties of similar objects in a particular Area.Example: In normal recording if we select the paint brush window, the script will look like this- window(Paint).Activate Window(Paint).Winobject(colors).Click 72,16 Window(Paint).Winobject(colors).Click 80,14 window(Paint).CloseIf we are using Virtual object, the script will look like this- window(Paint).Activate Window(Paint).Winobject(colors).Virtual Button(RED) Window(Paint).Winobject(colors).Virtual Button(BLUE) window(Paint).Close

    Dhananjay Singh

  • *Dhananjay Singh*Check Points-

    Check Point is a verification point that compares the current value of the specified property with the expected value for that property.There are 9 types of check points are available in QTP.They are-1) Standard Check Point2) Text/ Text Area Check Point3) Bitmap Check point4) Database Check Point5) Table Check Point6) Page Check Point7) XML Check Point8) Image Check Point9) Accessibility Check Point

    Dhananjay Singh

  • *Dhananjay Singh*

    Checkpoint Types

    Dhananjay Singh

  • *Dhananjay Singh*Inserting a Checkpoint During Recording-

    Dhananjay Singh

  • *Dhananjay Singh*Insert a Checkpoint After Recording-

    Dhananjay Singh

  • *Dhananjay Singh*Actions- Action is nothing but a logical portion to entire script file based on the requirement. Each and every action should have meaningful result.Types of Actions:1) Regular (By default)2) Reusable3) ExternalHow to work with Actions:1) Call to copy of Action2) Call to Existing Action

    Dhananjay Singh

  • *Dhananjay Singh*Data Driven Test-Testing the same application with multiple sets of data.How to use parameterization:Ex: Before parameterization Dialog(Login).ActivateDialog(Login).WinEdit(name).Set AxisDialog(Login).WinEdit(Password).SetSecureaxisittDialogLogin.CloseAfter Parameterization Dialog(Login).Activate Dialog(Login).WinEdit(Login name).Set DataTable(name, dtglobalsheet) Dialog(Login).WinEdit(Password). (password, dtglobalsheet) DialogLogin.Close

    Dhananjay Singh

  • *Dhananjay Singh*Using Data Sheet (Global, Local & Location)-

    Dhananjay Singh

  • *Dhananjay Singh*Setting the Parameter Value-

    Dhananjay Singh

  • *Dhananjay Singh*Test Results Iterations-

    Dhananjay Singh

  • *Dhananjay Singh*Exception Handling- It enables Quick test to detect and handle when unexpected error occurred during execution time.

    Types of Exception Handling:1) Popup Exception Handling2) Object State Exception Handling3) Test Run Exception Handling4) Application Crash

    Dhananjay Singh

  • *Dhananjay Singh*Object Identification- By using object identification we can map customer user defined object to standard Class.

    Two types of properties are their in object Identification:

    1) Mandatory Properties2) Assistive properties

    Dhananjay Singh

  • *Dhananjay Singh*Ordinal Identifier- By using ordinal identifier options quick test able to identify an object under ordinal identifier.

    Three Components are available in ordinal identifier1) Index2) Location3) Creation time

    Dhananjay Singh

  • *Dhananjay Singh*Smart Identification- Quick test unable to identify the object, it is change randomly. To identify such object we need to use Smart Identification.

    Two properties are available in Smart identification They are-1) Base Filter Properties2) Optional Filter Properties

    Dhananjay Singh

  • *Dhananjay Singh*Synchronization Point- Synchronization point maintains the time coordination between testing process and your application process.

    There are 4 types of synchronization points:1) Sync2) Wait, wait(5) or wait 53) Wait Property4) Exist

    Dhananjay Singh

  • *Dhananjay Singh*Regular Expressions- It enables quick test to identify test string with varying value (varying means changing) Regular Expressions can be used in the following areas:1) Check Points2) In parameterization3) Data Driven test4) Actions5) Exception Handling.etc

    Dhananjay Singh

  • *Dhananjay Singh*Using a Regular Expression-

    Dhananjay Singh

  • *Dhananjay Singh*Some Regular Expressions-

    ExpressionCharDescriptionPeriod.Matches any single characterAsterisk*Matches zero to any number of occurrences of the preceding characterPlus+Matches one to any number of occurrences of the preceding characterBrackets[A-Z][a-z]Matches a range of characters[0-9]Matches a range of numbers\wMatches any alphanumeric character including underscore\WMatches any non-alphanumeric characterDigit\dMatches any digit\d{4}Matches exactly four digits

    Dhananjay Singh

  • *Dhananjay Singh*How to work with Environmental variables- It is a special type of variable which is use to expose the data related to environment. Environment Variables

    Built Inuser defined

    InternalExternal

    Dhananjay Singh

  • Kinds Of ActionsNon Reusable ActionsReusable ActionsExternal

    By default Actions are Non Reusable

  • Creating the ActionsHow to make actions reusableIterationsAction parameters (Input & Output) Input Browser("Browser").Page("Gmail: Email from Google").WebEdit("Email").Set parameter("username") Output Parameter("TotalValue") = Browser("Mercury").Page("ListOfSales").WebTable("Orders").GetCellData(NumTableRows,"Total")

  • Call to NewCall to CopyCall to existingDifference in Call to Copy and Call to existingProperties of called function depends on the mode they are calledEditable Mode and Read Only ModeCalling the Actions

  • Understanding Expert View

    Dhananjay Singh

  • Understanding and Using the Expert ViewThe following diagram shows how the same object hierarchy is displayed inthe Expert View and in the Keyword View:

  • Expert View and Keyword View .. Cont The table below explains how the different parts of the same step arerepresented in the Keyword View and the Expert View:

  • Understanding Checkpoint and Output StatementsUnderstanding Parameter Indications

  • Understanding Parameter Indications. ContBefore Parameterization:

    Browser("Welcome: Mercury").Page("Find a Flight:").WebList("toPort").Select "San Francisco

    After Parameterization:

    Browser("Welcome: Mercury").Page("Find a Flight:").WebList("toPort").Select DataTable("Destination",dtGlobalSheet)

  • Generating Statements in the Expert ViewThe Expert View helps you to generate statements in three ways:

    You can use the Step Generator to add steps that use methods and functions.

    You can manually generate VBScript statements that use methods toperform operations.

    When you start to type a VBScript keyword in the Expert View, QuickTest automatically adds the relevant syntax or blocks to your script, if the Autoexpand VBScript syntax option is enabled.

  • For...Next Statement

    For counter = start to end [Step step]statementNext

    passengers = Browser("Mercury Tours").Page("Find Flights").WebEdit("numPassengers").GetROProperty("value")total = 1For i=1 To passengerstotal = total * iNextMsgBox "!" & passengers & "=" & total

  • For...Each StatementFor Each item In arraystatementNext

    MyArray = Array("one","two","three","four","five")For Each element In MyArraymsgbox elementNext

  • Do...Loop StatementDo [{while} {until} condition]statementLoop

    passengers = Browser("Mercury Tours").Page("Find Flights").WebEdit("numPassengers").GetROProperty("value")total = 1i = 1Do while i

  • If...Then...Else StatementIf condition ThenstatementElseIf condition2 ThenstatementElsestatementEnd If

    passengers = Browser("Mercury Tours").Page("Find Flights").WebEdit("numpassengers").GetROProperty("value")If (passengers < 4) ThenBrowser("Mercury Tours").CloseElseBrowser("Mercury Tours").Page("Find Flights").Image("continue").Click 69,5End If

  • Invoke Internet Explorer to run the test :Store the value of URL in startURL Variable from dtGlobal SheetstartURL = DataTable("url", dtGlobalSheet)

    Invoke internet Explorerset InternetExplorer = CreateObject("InternetExplorer.Application")

    To check whether i.e is open and maximisedInternetExplorer.Visible = true

    Navigate the required URL in ieInternetExplorer.Navigate startURL

  • Functions[Public [Default] | Private] Function name [(arglist)] [statements] [name = expression] [Exit Function] [statements] [name = expression] End Function

    ExampleFunction MyFunction(text) MsgBox text End Function

    How to call[Call] [Return value] Functionname (arglist)My Function (Hi to all)

  • Common functions used .Report Event :Reporter.ReportEvent EventStatus, ReportStepName, Details [, Reporter] Example The following examples use the ReportEvent method to report a failed step. Reporter.ReportEvent 1, "Custom Step", "The user-defined step failed." or Reporter.ReportEvent micFail, "Custom Step", "The user-defined step failed."

    Get Cell Data :object.GetCellData (Row, Column)

    Get Current Row :DTSheet.GetCurrentRow Examplerow = DataTable.GetSheet("MySheet").GetCurrentRow Reporter.ReportEvent 1, "Row Number", row

  • Common functions used .Get RO Property Method ( Returns a Variable ) :

    object.GetROProperty (Property, [PropertyData])

    Example: ActualDisabledVal = Browser("Browser").Page("Page").WebButton(Continue").GetROProperty("disabled")

    Exists Method :

    Example:Browser("Browser").Page("Page").WebButton(Continue").Exists

    Msgbox :

    MsgBox Value displayed is correct Or MsgBox ActualDisabledVal

  • Common functions used Trim Function :

    Dim MyVar MyVar = LTrim(" vbscript ") ' MyVar contains "vbscript "MyVar = RTrim(" vbscript ") ' MyVar contains vbscript"MyVar = Trim(" vbscript ") ' MyVar contains vbscript"

    Import / Export Function :Imports the specified Microsoft Excel file to the run-time Data Table. DataTable.Import(FileName) Example:DataTable.Import ("C:\flights.xls")

    Saves a copy of the run-time Data Table in the specified location DataTable.Export(FileName) Example:DataTable.Export ("C:\flights.xls")

  • Inserting Steps Using the Step Generator

  • Setting the Testing OptionsTo set global testing options:Tools > Options or click the Options toolbar button.

  • Recovery Scenario

    The Recovery tab displays a list of all recovery scenarios associated with thecurrent test or component. It also enables you to associate additionalrecovery scenarios with the test or component, remove scenarios from thetest or component

  • Object Repository vs. Descriptive Programming what to use?There really is no best wayUse the method that gives your company the best ROI, whether that be Object Repository (OR), Descriptive Programming (DP) or a mixture of both

  • OR Pros and ConsPROS:GUI Front end to examine all the objects in the repositoryHighlight in Application feature is great tool to walk the object treeNo need to modify the script when object properties changesEasy to identify objects in AUT by Object Logical namesCan be created independently from scripts

  • OR Pros and ConsCONS:Additional layer to maintainUnnecessary objects can be createdMultiple users cannot concurrently save/write to the shared ORIt wont eliminate the need for Descriptive Programming in most of cases

  • DP Pros and ConsPROS:Its a white boxCompatible with different QTP versionsCode portability is highEasy to mass update

  • DP Pros and ConsCONS:Lower Code Readability and requires more comments, like what object is accessedPotentially slower to create To highlight an object in the application requires utilizing the Highlight method

  • What is Object Repository?Object Repository is a place where QTP stores learned objects QTP uses default Object Identification properties: mandatory and assistive to learn objects into OR

  • Object RepositoryLogical NameProperties

  • OR: Object identification default properties

  • Script playback using ORQTP finds the Object in Object Repository using object Logical Name and Object HierarchyQTP retrieves Test Object properties from ORQTP searches actual application for the Object with the same properties as the OR Test Object and performs user action

  • Script playback using Descriptive programmingQTP searches the Application Under Test (AUT) for the Object using Descriptive properties and performs user action

  • Descriptive programming when and why?Consider using DP in following cases:Dynamic object propertiesExample: Link Logout Same objects on every pageExample: Buttons Next, Back, Cancel, OKLots of similar objects on one pageExample: table with many First & Last name text boxes

  • Different ways to work with objects

  • Different ways to work with objectsExample for Passenger 1 First Name

  • ChildObjects method using Collection Object

  • ChildObjects method using Collection ObjectLast Name fields are populated

  • TO, RO and .Object.GetTOproperty/SetToProperty refers to the properties stored in OR.GetROProperty property refers to the AUT Object property (Run-time).Object. refers to the AUT Object NATIVE properties/methods

  • Better names for Object Spy radio-buttonsRun-Time NATIVE ObjectRun-Time QTP (Test) Object

  • Object Run-Time Properties from AUT (GetRoProperty)

  • Run-Time Native Object Properties/Methods from AUT (.Object)

  • Test Object Properties from ORSet/GetToProperty

  • Regular Expressions in ORExample: Server independent Page object1. Click on Property value to access RegEx2. Click RegEx Icon

  • Regular Expressions in OR

  • Regular Expressions in ORRegEx icon

  • Object Smart IdentificationSmart Identification is not Artificial IntelligenceSI uses loose/unreliable object recognitionIts recommended to disable SI for each and every page/window/control using the Tools->Object Identification dialog (Recording)Another way to disable SI: File -> Settings -> Run -> Check the "Disable Smart Identification during run session" check box (Run-Time)

  • Smart Identification (SI) Recording OptionsSI Checkbox

  • Smart Identification (SI) Run OptionSI Checkbox

  • Driver ScriptBusiness ClassesGeneric ClassesRecovery ScenariosTest DataRepositoriesStatic Files(ini)A Brief Picture of Automation Framework

  • Components of Framework Generic ClassesBusiness ClassesRepositoriesTest DataRecovery Scenarios FilesStatic Info Files (ini Files)Driver Script

  • Generic ClassesThese Classes are generic to any application and not dependent on applications logic.Example : 1. Functions for Launching and Exiting AdvantEdge 2006 Definition :Class Functions and procedures will be defined hereEnd ClassCalling from script :ExecuteFile Library File PathLoad library files in to QTPSet Obj=New Declaring ObjectObj.Function/procedureCallingfunction/procedure Set Obj=NothingRemoves Object from memory

  • Business ClassesThese Classes are specific to applications business logic. And changed according to the business logic of application.Example : 1. A function for Calculating the P&I Formula. 2. Filling borrowers information.Definition :Class Functions and procedures will be defined hereEnd ClassCalling from script :ExecuteFile Library File PathLoad library files in to QTPSet Obj=NewDeclaring ObjectObj.Function/procedureCallingfunction/procedure Set Obj=NothingRemoves Object from memory

  • RepositoriesMultiple repositories will be prepared for better maintenance. (.tsr files)Repositories will be loaded in to driver script dynamically depending on the objects requirement. Refer AE2006_LoadRep(Rep_Path) in AE_2006_Utils.vbsRepository entries must maintain the standards defined in Coding Standards document.*Object identification script* must be used before adding any object to repository.All the ORs should be administered and should not be altered by the others with out permission.

  • Test DataAll the Test data should be maintained in Excel files. (.xls files)Example : Borrower InformationAnd dynamically loaded in to the script during the script execution.Loading Dynamically :Use AE2006_LoadTData in AE_2006_Utils.vbs(Or)DataTable.ImportSheet Data File path,Source Sheet,Dest Sheet

  • Recovery ScenariosApplication related errors and interruptions in script execution should be identified and recovery operations must be defined in recovery files.(.qrs) Example : 1. Any unwanted popup message that may appear during the script execution.These files must be loaded and activated before executing script.Activating / DeactivatingRecovery.Enabled=true Recovery operations activatedRecovery.Enabled=falseRecovery operations disabled

  • Static FilesAll the global and application related static data must be maintained in Static files(.ini).Example: 1. A static variable that holds AdvantEdge application path. This will be referred in all the driver scripts. If application path changes simply we modify the value in .ini file, that will be reflected across all the driver scripts.

    Static file architecture :[Environment]Env_Variable=value

    Accessing global/static info Environment.LoadFromFile path of Env File Environment.Value(Env_Variable)

  • Driver ScriptDriver Script is the main automation script from where the remaining Automation Components will be called.In Driver Script we create Objects to the Business and Generic classes to access the functions and procedures of them.Calling a Function or Procedure from a classSet Obj=New Class_NameCreates Object to ClassRet_val=Obj.MyFunctionAccesses a FunctionObj.MyProcedureAccesses a ProcedureSet Obj=NothingFrees up from memory

  • Driver Script ContFrom the driver script repositories will be loaded dynamically by using a generic function .(Refer : AE_2006_LoadRep function in AE_2006_Utils.vbs)

    Testdata will be called from test data files (.xls files) and it will be loaded in to the Datasheets during the test execution (run time).Importing a Sheet --DataTable.ImportSheet Data File path,Source Sheet,Dest Sheet

  • Driver Script ContRecovery scenarios will be loaded in to the test from Recovery Scenario Files(.qrs files).

    These scenarios help running the driver script smoothly even if any interruptions occurred during the execution.Enabling and Disabling Recovery Mechanism--Recovery.Enabled=True To activate the scenariosRecovery.Enabled=False To deactivate the scenarios

  • Driver Script ContIf global data need to be accessed by functions or procedures, Driver Script calls that data from Static Files (.ini files) and passes is it to the appropriate functioned and procedures.Loading an Static File ---Environment.LoadFromFile .ini file Path Loading fileEnvironment.Value(Variable) accessing variable

    In addition with Automation Components , driver script may contain Local User Defined Functions and Procedures

  • Supporting FilesCode template for writing the Scripts to improve readability and debugging capabilities.Refer AE2006_CodeTemplate.DocCoding standards document.(Yet to prepare)Refer AE2006_CodeStandards.DocLibrary mapping file to determine the usage of Library files.Refer AE2006_Libraries.xlsResponsibility Mapping file.(.xls) to determine who is working on what.Refer AE2006_Tracibility.xlsA start up Script to set the basic automation settings in QTP, like Object Identification settings and etc.Refer AE2006_StartUp.vbs

  • Driver ScriptBusiness ClassesGeneric ClassesRecovery ScenariosTest DataRepositoriesStatic Files(ini)Automation Framework Reviewed

  • *Dhananjay Singh*Comments & Queries-Queries are always welcome.

    Dhananjay Singh

    **************************************************************************************************