Вы находитесь на странице: 1из 53

Advanced QTP Training

IVS-TRAINING @

Ground Rules
Stick

to timeliness Help each other in learning as learning is a continuous process Please participate actively to make the session interactive.

IVS-TRAINING @

Session Objectives

A comparison between QTP and other testing automation tools Object Repository Type and Object Recognition Object Identification Recording Modes Context sensitive, Lowlevel and Analog Recording Virtual Objects Global Object Repository Implementing Global Object Repository Releasing Objects Regular Expressions
IVS-TRAINING @

Session Objectives (Contd)


Exception

Scenarios Integration with Test Director/Quality Center Summary References

Handling and Recovery

IVS-TRAINING @

A comparison between QTP and WinRunner Criteria


1. 2.

QTP
Windows

WinRunner
Windows, Citrix and Microsoft Terminal Server environments

Platform Browser

Netscape, IE, AOL, Applications Internet explorer all versions, with embedded Web browser Netscape 4.05 to 4.79 and 6.1,7.1 control. and above HTML, DHTML, Java Script, VBScript, Active X, Java Apps, MFC(C, C++) Legacy applications

3.

Technology Windows MFC (Microsoft Foundation Classes), Visual C+ +, Visual Basic, Web, Active X, Mainframe (3270/5250) and Microsoft .NET-based applications Script Language GUI Repository VBScript

4. 5.

TSL (Test script language)

Called Object Repository can be GUI Based stored on per-action basis or as Global Object repository
IVS-TRAINING @

A comparison between QTP and Compuware (QARun V4.8)


Criteria
1.

QTP

Compuware (QARun V4.8)

Browser

Netscape, IE, AOL, Applications IE 4.01+, Netscape Navigator 4.0.8, with embedded Web browser Netscape Communicator 4.5, 4.6, and control. 4.7 Web, Java, ERP/CRM, Character based wireless and PDA Applications, Client/Server applications and emulator based applications: UNIFACE, Siebel, SAP, Oracle, PeopleSoft and PowerBuilder QA Run Script

2.

Technology / Windows MFC (Microsoft Protocols Foundation Classes), Visual C+ +, Visual Basic, Web, Active X, Mainframe (3270/5250) and Microsoft .NET-based applications Script Language GUI Repository VBScript

3. 4.

Called Object Repository can be GUI / Text stored on per-action basis or as Global Object repository No

5.

Run from Yes any point in script Watch Window Yes

6.

No
IVS-TRAINING @

Object Repository Type and Object Recognition

IVS-TRAINING @

Object Repository Type and Object Recognition (Contd)


Types of Object Repository Local object repository Global object repository Local object repository Default repository Specific to actions (Will be used only for a particular action) Preferable when application is not dynamic with respect to time Cannot be reused
Example Here Action1 and Action 2 of same test will have different object repositories.

IVS-TRAINING @

Object Repository Type and Object Recognition (Contd)


Global Object Repository Can be updated by all actions accessing it Preferable when application is dynamic with respect to time Global object repository Used in most automation projects may be common to all Needs maintenance and administration tests and to all actions inside each test
Global object repository
Test1 Test2 Test3

Action1

Action2

Action3

Action1

Action2

Action3

Action1

Action2

Action3

IVS-TRAINING @

Object Repository Type and Object Recognition (Contd)

Utilities Provided with the latest version Object Repository maintenance is one key area concentrated on in the latest version of QTP. For maintenance of repository, few new options have been provided like :

Object Repository Manager


This utility helps in editing a repository file (*.tsr). Any object repository file can be opened and simple changes like adding an object, editing or modifying an existing object or deleting and object can be performed. Associate Repositories Any repository that is loaded should be associated to appropriate action. This utility helps the users in associating different global repositories to specific actions.

IVS-TRAINING @

Object Repository Type and Object Recognition (Contd)


Object Repository Manager

Object Repository Editing

IVS-TRAINING @

Object Repository Type and Object Recognition (Contd)


Object Identification User can specify properties to be used for identification in order to distinguish between two objects of the same class object.

IVS-TRAINING @

Object Repository Type and Object Recognition (Contd)


Configuring Mandatory and Assistive Recording Properties: Mandatory properties: QTP has list of mandatory properties, for each type of object, which it always learns. When we run the script QTP uses all the mandatory properties to identify the object. It uses assistive properties when mandatory properties are not enough to identify an object.

IVS-TRAINING @

Object Repository Type and Object Recognition (Contd)


We can change the mandatory properties or assistive properties based on the application. We can add /remove few properties in mandatory properties or assistive properties so that QTP identifies the object when we run the script

IVS-TRAINING @

Object Repository Type and Object Recognition (Contd)


How to change properties of objects? Tools Object Identification Object Identification dialog box opens Choose the Environment you are going to work on. Eg: Web, Windows, Visual Basic Choose the required object under the environment. Eg: Link, WebButton for Web Select the properties you want to make mandatory or assistive by selecting the option

Options are available to the user Selected properties will be made mandatory in this case Selection of properties should be based on nature of application Same is applicable to assistive properties

IVS-TRAINING @

Object Repository Type and Object Recognition (Contd)


Recording a link

Example

ADP
Mandatory Properties: Html tag: Text: Inner Text: Assistive Properties: Name: Outer text: URL: Color: Font: adp Adp www.adp.com red Arial During recording QTP has stored both the mandatory as well as assistive properties for identifying the particular link. Lets check why? A ADP adp

IVS-TRAINING @

Object Repository Type and Object Recognition (Contd)


Capturing Mandatory Properties Mandatory Properties: Html tag: Text: Inner Text: Assistive Properties: Name: Outer Text: URL: Color: Font: A ADP ADP Starts using assistive properties and checks object ADP ADP
Includes 1st Property Includes 2nd Property Includes 3rd Property

ADP
Checking to identify the object using Checking to identify the object using Checking to identify the object using the captured identify the properties mandatory Checking to identify the object using the captured mandatory properties Checking to identify the object using the captured mandatory properties Checking tois mandatory properties object using the capturedassistiveidentify the link Now QTP 1 able to property andwith 2 assistive properties with the captured mandatory properties and with 3 assistive properties the captured 3 Mandatory properties and with 4 assistive properties with captured mandatory properties and with 5 assistive properties andand 5 Assistive properties!!

www.ADP.com Blue Arial


5th
4th

QTP uses Assistive properties if the stored Mandatory properties are not enough to identify an object
IVS-TRAINING @

Object Repository Type and Object Recognition (Contd)


Selecting an Ordinal Identifier: In addition to mandatory properties and assistive properties, QTP records backup ordinal identifier for each test object Used when QTP is not able to identify an object with captured mandatory properties and assistive properties during recording, In other words, Ordinal identifier is used if mandatory properties and assistive properties captured by QTP is insufficient to identify an object in the application during record session.

During a record session

If mandatory properties and assistive properties are insufficient to identify an object during record session

QTP uses Ordinal Identifier in addition to other captured properties to identify the objects during a record session

IVS-TRAINING @

Object Repository Type and Object Recognition (Contd) Types of Ordinal identifiers: 1.Index based 2.Location based 3.Creation Time
Index: Indicates the order in which the object appears in the application code relative to
other objects. Eg., pressing a tab and giving numbers to objects

Location : Indicates the order in which the object appears within the parent window, frame,
or dialog box relative to other objects with an otherwise identical description

CreationTime (Browser object only) : Indicates the order in which the browser was
opened relative to other open browsers with an otherwise identical description.

An ordinal identifier is selected by default for each test object class. To modify the selected ordinal identifier, select the desired type from the Ordinal identifier box.

IVS-TRAINING @

Object Repository Type and Object Recognition (Contd)


Setting up which ordinal identifier to use during object identification: User can select which ordinal identifier to be used by selecting the options in object identification The ordinal identifier in web will have three options namely Index, Location and Creation time. This Creation Time is not available in the ordinal identifier options of other environments.

Options for Web

Options for other environments

Identifying an Object Using the Index Property:


QuickTest can assign a value to the Index test object property of an object The value is based on the order in which the object appears within the source code. The first occurrence is 0.

IVS-TRAINING @

Object Repository Type and Object Recognition (Contd)


Identifying an Object Using the Location Property: During recording, QuickTest can assign a value to the Location test object property of an object in order to uniquely identify the object. The value is based on the order in which the object appears within the window, frame, or dialog box, in relation to other objects with the same properties. First occurrence value = 0 Values are assigned in columns from top to bottom, and left to right.

Example:
Numbered based on location property

IVS-TRAINING @

Object Repository Type and Object Recognition (Contd)


Configuring Smart Identification: Configuring Smart Identification properties enables you to help QuickTest identify objects in your application, even if some of the properties in the object's recorded description have changed. About Configuring Smart Identification: QTP uses object description for identifying an object. If its not able to identify the object with the description, then it goes for smart identification mechanism. Smart identification uses two types of properties and are base filter properties and optional filter properties Base filter properties: Most fundamental properties of object class or values which cannot be changed without changing the essence of the original object. Eg., if a Web link's tag was changed from <A> to any other value, you could no longer call it the same object. Optional properties: Other properties to identify objects for a particular class as they are unlikely to change on regular basis, but can be ignored if they are not applicable.
IVS-TRAINING @

Object Repository Type and Object Recognition (Contd)


Step-by-step Instructions for Configuring a Smart Identification Definition: Tools > Object Identification. The Object Identification dialog box opens. Select the appropriate environment in the Environment list. The test object classes associated with the selected environment are displayed in the Test object classes list. Select the test object class you want to configure. Click the Configure button next to the Enable Smart Identification check box. The Configure button is enabled only when the Enable Smart Identification option is selected. The Smart Identification Properties dialog box opens:

IVS-TRAINING @

Object Repository Type and Object Recognition (Contd)


Base filters & Optional filters: In the Base Filter Properties list, click Add/Remove. The Add/Remove Properties dialog box for base filter properties opens. Select the properties you want to include in the Base Filter Properties list and/or clear the properties you want to remove from the list.

Click OK to close the Add/Remove Properties dialog box. The updated set of base filter properties is displayed in the Base Filter Properties list. In the Optional Filter Properties list, click Add/Remove. The Add/Remove Properties dialog box for optional filter properties opens. Same applies for optional properties also. Use the up and down arrows to set your preferred order for the optional filter properties.
IVS-TRAINING @

Object Repository Type and Object Recognition (Contd)


Recording Modes Context sensitive, Low-level and Analog Recording Context sensitive: This is the Default mode of recording which takes full advantage of QuickTest's test object model. Records the objects in your application and the operations performed on them. Recognizes objects in application regardless of their location on the screen. Analog Recording: Records the exact mouse and keyboard operations you perform in relation to either the screen or the application window. QTPs Analog recording is captured as Tracks and stored in the directory of your test Useful for recording operations that cannot be recorded at the level of an object. Eg., A signature produced by dragging the mouse in a paint will be recorded in analog recording

MS Paint If recorded using Context sensitive mode, You will not get any drawing during playback

MS Paint If recorded using Analog mode, You will be able to replay it back successfully

But Beware! Avoid Scripting in ANALOG Mode as far as possible.


IVS-TRAINING @

Object Repository Type and Object Recognition (Contd)


Recording Modes Context sensitive, Low-level and Analog Recording Low Level Recording: Enables you to record on any object in your application, whether or not QuickTest recognizes the specific object or the specific operation. Records at the object level and records all run-time objects as Window or WinObject test objects. Used when the exact coordinates of the object are important for your tests. Used when recording tests in an environment (or on an object) not recognized by QuickTest.

IVS-TRAINING @

Object Repository Type and Object Recognition (Contd)


Virtual Objects Substitutes for standard objects Used when standard objects cannot be recorded due to problems that arise during recording. Virtual objects cover the regions in the application that QTP has failed to identify. Scenario: During recording, QTP can fail to identify certain objects in the application screen. We will not be able to proceed on with recording the remaining part of the script without the line. Create virtual objects and start recording. That particular part of application will be covered and marked as virtual object in the script. By creating virtual objects, user can avoid scenarios which may stop automation of a test scenario. Eg., Try creating a cell in excel sheet as Virtual Object and try recording it and check the script
The following example clicks the "button" VirtualButton. Syntax: Browser(X").Page(Y").ActiveX(Z").VirtualObject(A").Click
IVS-TRAINING @

Object Repository Type and Object Recognition (Contd)


Defining a Virtual Object: Click Tools > Virtual Object > New Virtual Object You will get the steps as mentioned below
Step1 Step2

Click Next

Class can be Object, Button, Table, List, Check box & Radio button. Mark a class based on the object which is present in the application Eg., Mark radio button from the drop down shown, if QTP has failed to identify a radio button in the application during recording a script

Next page for next step

IVS-TRAINING @

Object Repository Type and Object Recognition (Contd)


Step3
Click Mark Object button (The QTP screen is minimized) You will get a cross hairs pointer. Use the cross hairs pointer to mark the object in application

Step4

You can select entire parent hierarchy or parent only

Step6

Step5

Add virtual object to a collection

IVS-TRAINING @

Exception Handling and Recovery Scenarios

IVS-TRAINING @

Exception Handling and Recovery Scenarios


On Error Resume Next : This statement causes execution to continue, despite a run-time error. On Error Go to 0 : This statement is used to disable error handling, if it is previously enabled using On Error Resume Next. Debugging : In QTP there is a window called Debugging window which contains three tabs Watch Expressions Variables Command Watch Expressions:

If the user is concerned about one or more specific variable value or values of some vbscript expression, then the user can enter those variable names in the first column of the watch expression tab. When the test case is run in a step-by-step mode using breakpoints, we can see the current value of the variables/ vbscript expression entered in the first column of the watch expression tab.
IVS-TRAINING @

Exception Handling and Recovery Scenarios (Contd)


Variables: User can check all the initialized variables and their values during the program execution in the Variables tab. Entire initialized variable names and its current value are displayed. During program execution if the value of any variable changes, the same will get reflected in the Variables tab. Hence the user can easily analyze the code with this.

Commands: This tab helps in modifying the values of the variables at run time (while executing the script in step-by-step format). During execution, user can insert breakpoint and the execution will suspend when it reaches any break point.
IVS-TRAINING @

Exception Handling and Recovery Scenarios (Contd)


Let us assume the variable strVarName = very good. At this point the user can enter the variable name and assign the new value to check whether the code works fine, if new value is assigned at this moment.

For eg. the user enters strVarName = Hi this is the new value in the Command tab. After entering the new value, if the user starts running the script from that step, the new value will be considered as the current value of the variable. By changing the variable value during the execution time, user can make sure if the variable attains the mentioned value.
IVS-TRAINING @

Exception Handling and Recovery Scenarios (Contd)


Automation of QTP: Let us discuss two scenarios where automation of QTP is preferred. 1. When more users are involved in an automation project then the scripts generated by these users may not be of same standards and hence integration of scripts gives problems. 2. When automated scripts are moved to client, in client location, we may need to do configuration of QTP and associate other files/paths such as library files, folder paths, recovery scenario files, environment files etc... In both these cases lot of effort is required and the person who is doing such configuration must be very sure of what he is doing, otherwise proper execution of the script wont happen. We can easily create such programs by utilizing the Generate Script functionality provided in QTP. This Generate Script functionality is provided in three places From these three sections, we can create 3 VBScript files, which can be combined together to create a final VBScript file, if required which can perform all the above mentioned functionalities.

IVS-TRAINING @

Exception Handling and Recovery Scenarios (Contd)


Generate Script Object Identification: In this section we can set the Mandatory properties, Assistive properties, Smart Identification configuration etc for all kinds of objects for all the loaded add-ins.

IVS-TRAINING @

Exception Handling and Recovery Scenarios (Contd)


Generate Script Test Settings : Through the highlighted button, we can generate the script which will set the associated add-ins with this test case, Run options (Run on all rows, Run one iteration only... for global sheet) Library files, Parameters, Recovery scenario files, Load environment variable files, Browser navigation timeout settings, Username and Password settings for accessing the application through the Active screen. The easiest way to create the custom file is by setting the proper configuration once, and generate the script with the help of this button.

IVS-TRAINING @

Exception Handling and Recovery Scenarios (Contd)


Generate Script Tools/Options : In the above mentioned section we can create the script to control the general settings which are applicable for all the test cases. We can set the folder paths, amount of information that should be captured through Active screen, enable/disable the integration of QTP with other mercury tools, execution mode (Fast/Normal), capturing of screen shots during (error, always, never, on errors and warnings), and advance web settings.

IVS-TRAINING @

Exception Handling and Recovery Scenarios (Contd)


Optional Steps : When running a test or component, if a step in an optional dialog box does not open, QuickTest will bypass this step and continue to run the test. When the run session ends, a message is displayed for the step that failed to open the dialog box, but the step does not cause the test or component to fail.

To set an optional step in the Keyword View, right-click a step and choose Optional Step. The Optional Step icon is added next to the selected step. An optional step can be added in the Expert View by adding OptionalStep to the beginning of the VBScript statement. Example: OptionalStep.Browser("browser_name").Page("page_name").Link("link_name")
IVS-TRAINING @

Exception Handling and Recovery Scenarios (Contd)


Recovery Scenarios : Unexpected events, errors, and application crashes during a run session can disrupt your run session and distort results. This problem may stop execution of tests. The Recovery Scenario Manager provides a wizard that guides you through the process of defining a recovery scenario A recovery scenario consists of the following: Trigger EventThe event that interrupts your run session. For example, a window that may pop up on screen, or a QuickTest run error. Recovery Operation(s)The operation(s) that need to be performed in order to continue running the test or component. For example, clicking an OK button in a pop-up window, or restarting Microsoft Windows. Post-Recovery Test Run OptionThe instructions on how QuickTest should proceed once the recovery operations have been performed, and from which point in the test or component QuickTest should continue, if at all. For example, you may want to restart a test or component from the beginning, or skip a step entirely and continue with the next step in the test or component.
IVS-TRAINING @

Steps for creation

Exception Handling and Recovery Scenarios (Contd)

Step6: Step5: Define any without making any Manager Step4: Enter on New Scenario event changes Step3: Selectappropriate information you require Step2: Next Tools > the triggerScenarioclick on next button Step1: Click buttonof Recovery button based on your trigger event a recovery operation and

IVS-TRAINING @

Steps for creation Contd

Exception Handling and Recovery Scenarios (Contd)

Step12: Step11: Step10: you need recovery scenarios proceed on available Next Step9: Clickappropriate like to quit or and click likenext buttonoptions Step8: IfEnter finishanotheroperation operation checkmouse operation Step7: Enter the recoveryinformationyou require withprevious choice Scenario Name and add a description the click post if you recovery based on your and check box

IVS-TRAINING @

Exception Handling and Recovery Scenarios (Contd)


Care must be taken when you are adding more than one recovery scenario in a script.

Since there is limited time for the Recovery Scenario to kick off, the most frequently used recovery scenario should be at the top of the list and the list should later be refined as the interaction with the AUT increases.

Recovery scenarios do not get executed when QTP is in a Wait loop,

i.e. if we have a wait statement after a particular step (say for about 15 sec) then the Recovery Scenario will not get executed for the entire wait period and in the meantime it is quite possible that the AUT has moved from the screen that was expected resulting in a failure of the Recovery Scenario

IVS-TRAINING @

Integration with Quality Center

IVS-TRAINING @

Introduction:

Integration with Quality Center

Test Management tool from Mercury Interactive Using Quality Center we can manage the Requirements, Create Test cases, Execute test cases, report results and map all these together and create reports, schedule the execution of Test cases etc.

Why to Integrate QTP with Quality Center? Automated test cases through QTP can be directly stored in to Quality Center. With little configuration, we can integrate Quality Center with QTP and we can run test cases directly from Quality Center. We can directly store test cases to Quality Center with the option Quality Center Connection available in QTP. Test results will be automatically updated in the Quality Center if we run the automated scripts through Quality Center.

IVS-TRAINING @

Integration with Quality Center (Contd )


Integration with Quality Center
Steps involved in integration of Quality Center with QTP is as follows:

Step1: Enable this settings in the Options tab

Step2: Click on Quality Center Connection


or Tools > Quality Center Connection

IVS-TRAINING @

Integration with Quality Center (Contd )


Integration with Quality Center
Steps Contd Step3: Quality Center Connection wizard will open Step4: Enter Valid Domain, Project, User Name and Password and click Connect

Enter link of Quality Center server and click on connect button

Add Domain, your project name, user name and password provided for Quality Center in appropriate boxes and click on connect button

IVS-TRAINING @

Integration with Quality Center (Contd )


Integration with Quality Center
Steps Contd Step:4 Once Quality Center connection is established, Project connection section will get enabled and it will display all the possible Domain and projects present in that Quality Center server. Step:5 Select the correct Domain, Project and enter the User name and Password given to you for connecting to Quality Center and click Connect. Step:6 Save password and Reconnect on start up can be checked to perform such actions.

IVS-TRAINING @

Integration with Quality Center (Contd )


Integration with Quality Center
A tip to include the details for enabling the automatic Defect Reporting in TD/Quality Center, when running the scripts from the same.

When the check box Submit a defect to Quality Center is checked, the defect will be reported automatically in TD.
IVS-TRAINING @

Disadvantages/Difficulties faced during automation using QTP


1)

2)

3) 4) 5)

6) 7)

While using QTP: The object that QTP is trying to access may not exist or is disabled. For e.g. while trying to access a particular Button, the button may be disabled. In that case a runtime error would be thrown by QTP. Proper exception handling has to done in such cases. If an action is being called in a script then the local data sheet of that script is Read Only in the calling Script. This does not allow the data to be modified. The workaround would be to keep all the data that is needed to be modified in the Global data sheet of the action. The hierarchy of actions has to be taken care of, i.e., the previous action should end only where the new action is to begin. Care should be taken that the settings on the PCs where the script is made and the script is run should be same. For this the Generate script command is used. Care should be taken that actions calls are not hard coded to make the scripts generic. The folders should be properly mapped from the a centralized location so that every one running the script should be able to successfully run the script. Recovery scenario are not invoked if QTP is in wait state and this is not mentioned anywhere in help either. TE add - in for QTP doesnt support all TE applications. Only a selected few environments are supported.

IVS-TRAINING @

Summary
This presentation has described the following features of QTP for advanced learners. Why QTP is the preferred choice for automation now days Basics about object identification Global Object Repository Exception Handling and Recovery Scenario concepts Analysis of Results Integration with Quality Center Some points to keep in mind while using QTP

IVS-TRAINING @

References
Quick Test Pro 9.5 Help Quick Test Pro 9.5 Tutorial

IVS-TRAINING @

Q&A

IVS-TRAINING @

Thank You!!

IVS-TRAINING @

Вам также может понравиться