138
Automation Fundamental Automation Fundamental Concepts Concepts and and Intro. about QTP 10.0 Intro. about QTP 10.0

QTP With Descriptive Programming

  • Upload
    fgaffy

  • View
    133

  • Download
    3

Embed Size (px)

Citation preview

Automation Fundamental Concepts and Intro. about QTP 10.0

Automation Fundamental Concepts

What is Test Automation ?

Software Test Automation is the process of automating the steps of manual test cases using an automation tool Or utility to shorten the testing life cycle with respect to time When application undergoes regression, some of the steps might be missed out or skipped which can be avoided in Automation Automation helps to avoid human errors and also expedite the testing process To implement the Test Automation detailed planning and effort is required

Automation Fundamental ConceptsAutomation saves time and effort which results in reduction of the Test life cycle Benefits of Automation - Consistency of Test Execution - Reducing cycle time of regression test cycles - Data driven testing - Repeatability - Coverage - Reliability - Reusability of test wares

Automation Fundamental ConceptsAutomation life cycle is a subset of the entire test life cycle Automation planning can be initiated in parallel to the test planning phase Factors to be considered in automation planning, Stability of AUT (Application under test) No of regression cycles to be performed Compatibility of App platform with testing tools Cost benefit analysis (ROI) Availability of skilled resources

Regression Testing & AutomationWhen Automation is applicable? Regression Testing Cycles are long and iterative. If the application is planned to have multiple releases / builds If its a long running application where in small enhancements / Bug Fixes keeps happening Test Repeatability is required

Technologies SupportedDefault Support 1. Standard Windows applications 2. Web objects / Applications 3. ActiveX controls 4. Visual Basic applications Supported Add-ins AddQuickTest Professional Java Add-in 9.1 AddQuickTest Professional .NET Add-in 9.2 AddQuickTest Professional Oracle Add-in 8.2 AddQuickTest Professional PeopleSoft Add-in 8.2* AddQuickTest Professional Add-in 8.2 for SAP Solutions AddQuickTest Professional Siebel Add-in 8.0* AddQuickTest Professional Stingray Add-in 8.2 AddQuickTest Professional Terminal Emulator Add-in 8.0* AddQuickTest Professional VisualAge Smalltalk Add-in 8.2 AddQuickTest Professional Web Services Add-in 9.2 Add-

Supported BrowsersMicrosoft Internet Explorer 6.0 Service Pack 1 Microsoft Internet Explorer 7.0 Netscape Browser 8.1.2 Mozilla Firefox 1.5 Mozilla Firefox 2.0

AddAdd-in ManagerDefault Add-ins Add ActiveX Visual basic Web Other Add-Ins Add Siebel Java SAP Oracle .Net and many more

AddAdd-in Manager Cont Cont QTPs Add-in Manager facilitates the users to select the technology / environment from Addvariety of environments suitable for the AUT (Application Under Test) Once an add-in is loaded, users can record that application in its supported environment addand thus QTP recognizes the objects specific to the application under test (AUT) as loaded through Add-in Manager. Add It is critical for the users to know the development technologies / environment of AUT, and load right Add-Ins while invoking Quick Test Pro. Add-

Mercury QuickTest ProfessionalIntroduction to QTP QuickTest Professional, the Mercury advanced keyword-driven testing solution keywordenables you to test standard Windows applications, Web objects, ActiveX controls, and Visual Basic applications. You can also acquire additional QuickTest add-ins addfor a number of special environments (such as Java, Oracle, SAP Solutions, .NET Windows and Web Forms, Siebel, PeopleSoft, Web services, and terminal emulator applications).

QuickTest WindowThe QuickTest window contains the following key elements:

QuickTest title barDisplays the name of the currently open test or component. bar Menu barDisplays menus of QuickTest commands. bar File toolbarContains buttons to assist you in managing your test or component. toolbar Testing toolbarContains buttons to assist you in the testing process. toolbar Debug toolbarContains buttons to assist you in debugging your test or component (not toolbar displayed by default). Action toolbarContains buttons and a list of actions, enabling you to view the details of toolbar an individual action or the entire test flow. Test paneContains the Keyword View and Expert View tabs. pane Active ScreenProvides a snapshot of your application as it appeared when you Screen performed a certain step during the recording session. Data TableAssists you in parameterizing your test or component. For a test, the Data Table Table contains the Global tab and a tab for each action. For a component, the Data Table contains single tab. Debug Viewer paneAssists you in debugging your test or component. The Debug Viewer pane pane contains the Watch Expressions, Variables, and Command tabs (not displayed by Expressions, Variables, default). Status barDisplays the status of the QuickTest application. bar

QTP - Main Window

QTP - Main WindowTest Pane: Test Pane contains two labs to view the tests, - Keyword View - Expert View Keyword View: Quick Test Pro displays your test in the form of a collapsible, icon based tree Expert View: Quick Test Pro displays the source code (VB Script) of the tests in this view.

QTP Window

1. Prepare to RecordObjectivesReview documented user steps of a business transaction. Understand the application under test and its environment. Prepare the test environment to utilize QuickTest Professional correctly.

Quick Test Professional - Record & Run ModesRecording Modes Normal Analog Low level Run Modes Normal Fast Update

Quick Test Professional -Tools Options General

Click on Restore Layout button to reset screens to the initial setting when QuickTest was first installed.

QuickTest Professional Options->General Options-

A best practice when setting general options for QuickTest are to: Deselect all check boxes except Save data for integrating with performance testing and Display Add-in Manager on startup. Click on Restore Layout button to reset screens to the initial setting when QuickTest was first installed.

Quick Test Professional - Tools Options Run

Quick Test Professional - Options RunBest Practices for Options for Run Mode:

Run Mode as Normal:This ensures that the execution arrow appears to help with trouble shooting the tests. Synchronization becomes better for the AUT (Application Under Test)

Test Results:Deselect the option View Results when run session ends

Mercury Tool Integration:Select "Allow other Mercury products to run tests and components

Screen Capture:Save step screen capture to results "On error and warnings"

Automation Record and Run Settings

Record and Run SettingsBest Practices for Record & Run Settings Set the options to configure QTP to "Record and run test on any open WindowsWindowsbased application

Set the option - This window will appear the first time you click on the Record button in the new test. Manually recall this window by selecting Automation Record and Run settings

2. Create a TestObjectives Create a basic test from a manual test case. Run a test and check for errors. Store the test file. Discuss the importance of initial and end conditions.

The User Interface

The QuickTest Professional user interface is broken up into a number of functional areas. You can choose to focus on one or more areas depending on the task you are performing.

Record a Test

Once the record button is pressed and test steps are performed , QuickTest listens and records the activities. This results in the recording and storing of each step of the business process. Each step consists of: The object The method (operation) The method property (a value for the action performed on the object) QuickTest should be running before the application under test is invoked. For some environments, this is mandatory.

Saving a TestSaving the test in Quality Center Only relevant when using QTP with QC A bulls-eye symbol in the header with Open Test from Quality Center appears bullsA folder structure is listed under the parent directory Subject You have the option to click the File System button on the upper right corner Once you have logged into Quality Center: 1. Select your folder 2. Type in the test name 3. Save the file Save a test in QuickTest Professional If you are using QuickTest Professional alone the file system you will save to is under the QuickTest Professionals test directory. You have the option to save the test results along with the test.

Steps to Run a Test

From the QTP Toolbar, click on the Run Button. A best practice is to use the temporary folder to hold the results while debugging your test. Press the OK button to execute the Run command.

Viewing the Test Run

When you run a test, QuickTest performs each step as it was recorded. You can watch in the AUT as QuickTest performs each step. A yellow arrow in the left margin of the KEYWORD VIEW points out the step currently running. When QuickTest finishes running the test, you can open the Test Results window.

Steps to View the Results

1. 2. 3. 4. 5.

Decide if results must be viewed. If yes, select TEST->RESULTS from the QTP menu bar. View the outcome of the test run. Expand the results tree. From the Test Results menu bar, select VIEW->EXPAND ALL

View Test Results

Failure roll-up to the parent at the top level of the tree. Expand the Test Results tree to see the outcome of each step. Navigate to the child step that caused the failure.

3. The Object RepositoryObjectives Define what a Quick Test Professional object is. Describe the role of the Object repository Identify a given object as part of a class. Describe how objects are recognized by Quick Test Professional. Use the Object Repository to find and add objects. Change object logical names using the Keyword View.

Object Types

A Quick Test Professional object is a graphic user element in an application, such as a button or a drop-down list. dropObjects are categorized into classes. Buttons, Graphic Images and Edit Boxes are a few examples of class types.

QuickTest Object Properties

In the example above, there are several objects called Buttons, two of which are: Update Order Delete Order. The only way to distinguish one object from the other of the same class is by the difference in object characteristics. Specific characteristics of an object within QuickTest are called object properties.

QuickTest Recognizes ObjectsQuickTest uses a method when it learns objects during the recording process. QuickTest first looks at the object you are recording and stores it as a test object, determining its object class. For example, QuickTest might classify the test object as a standard Windows dialog box or a web button. For each object class, QTP has a default set of properties that it always learns. Usually, only a few properties are needed to uniquely identify an object.

Assigning a Logical Name

After learning the class and properties of an object, QTP assigns a name to the object. This is known as the objects logical name. QTP refers to the object in a recorded test by using its logical name. Edit the logical name to make it more descriptive if you wish. The logical name given to an object during recording may be sufficient, but changing a logical name can give clarity to the test and the documentation that is generated.

Stored Test Objects

Recorded object properties are stored in QTPs Object Repository. Each test has its own Object Repository, by default.. These stored objects are referred to as Test Objects. The purpose of a Test Object is to represent application objects in the test. During a test run, QTP uses the Test Object to search for a match in the application during run time.

Steps to change A Logical Name

You can change an objects logical name in the OBJECT REPOSITORY. 1. Right-click on the object at the KEYWORD VIEW level. Right2. Choose OBJECT PROPERTIES. 3. Click on the REPOSITORY button.

The Object Properties Dialog

Once in the Object repository: 1. 2. 3. 4. RightRight-click the object in the repository tree. Choose RENAME. Type a descriptive name for the object. Click OK.

Quic

est

cume tati

Quic est updates the bject ame a d d cume ts it i the d cume tati field f the Keyw rd View. IMPOR AN : if y u start a bra d ew test, the test will rec rd the rigi al, default bject ames i the Object Rep sit ry.

4. SynchronizationObjectives Define Synchronization. How to synchronize the Test Some Visual Cue Examples Examine when and where synchronization is most helpful. Add a synchronization step for a specified object.

What is Synchronization ?

Synchronization is a step added to a test that instructs QuickTest to wait for the state of a property on a particular object to change before proceeding to the next step in the test. This is done while in RECORD mode. The user/test waits for a visual indication that a step has completed so that the user/test can take the next step.

How to synchronize the Test

We can synchronize the test by 1.Inserting a synchronization point Insert Step Synchronization point Window(Flights).WinButton(Update order).WaitPropertyenabled,1,1000 2.Adding Exist and Wait statements status=Window(Flights).Dialog(Flights Table).Exist Wait(10)

Some Visual Cue ExamplesSynchronization point enables the anticipated time problems between the application and QTP. A progress bar reaches 100% completion. A status message appears. A button becomes enabled. A window opens and is ready for data entry. A pop-up message appears in response to an operation. pop-

Examine the Application

Quick Test defaults to allocating the same amount of time for every object. Wait times often occur before an object becomes available for the next step. For example, in the Flights application, once the Insert Order button has been clicked, a process bar must complete to yield the Order No. associated with the reservation. The process bar may require additional time before the test can proceed. If insufficient time is allocated for these special circumstances, the test may fail. The error message Object not enabled appears if QuickTest is running a test and proceeds to the next step before the previous step has fully processed.

Add a Synchronization Step While Recording

Synchronization points which instruct QuickTest to pause until an object property achieves a specific value. The easiest method is to add a synchronization point while recording. A Synchronization step can be added manually after a test is recorded , as well. Always add the synchronization point immediately after the step to be synchronized. From the QTP menu bar, choose INSERT STEP SYNCHRONIZATION POINT

5. Object RepositoryObject Repository is a place where QTP stores learned objectsQTP uses default Object Identification properties: mandatory and assistive to learn objects into OR

Object Repository

Logical Name Properties

OR: Object identification default properties

Resources

Object RepositoryCan add a New Object to the repository

The value of property can be edited here. More properties for recognizing the object can be added to the list.

Resources Object Repository Manager

Resources Associate Repositories

Add shared Repository

Resources Object Repository

Associate repository is added to the Filter option.

Object Repository Merging tool

Primary Repository.

Secondary Repository

Object Repository Comparison Tool

Comparing two repositories'

6. CheckpointsA checkpoint is a verification point that compares a current value for a specified property with the expected value for that property. We can Insert checkpoint 1.From Menu Insert Checkpoint Standard Checkpoint 2.From Keyword view 3.From the Active Screen

Checkpoint Types1.Standard Checkpoint 2.Image Checkpoint 3.Table Checkpoint 4.Page Checkpoint 5.Text Checkpoint 6.Text Area Checkpoint 7.Bitmap Checkpoint 8.Database Checkpoint

Insert A Checkpoint From The Active ScreenA checkpoint can be added after a test is created. Use the Active Screen to select the field on which the checkpoint will be added. RightRight-click on the appropriate field and choose Insert Standard Checkpoint.

Regular ExpressionsRegular expressions enable Quick Test to Identify Objects and text strings with varying values.

Use a Regular ExpressionA regular expression is a string that specifies a complex search phrase. By using special characters you define the conditions of the search. Note: There are 4 steps to ensure that a regular expression is inserted correctly. From the Checkpoint Properties window, ensure Constant is enabled and click on the note paper icon. Check Regular Expression checkbox. If QTP sees there are characters that can be misconstrued as a regular expression, it will ask you to treat it as a literal character. Generally, you will answer No. Add the regular expression. For example, Figure 6-6 will use [A-Z a-z]+. 6[A- a-

7. ParametersObjectives Describe and use multiple parameter types. Drive data in multiple iterations. Analyze errors during iterations. Parameterize a checkpoint.

Input Parameters For Data driven TestsInput Parameters For Data Driven Tests A data-driven test is one that runs a set of user actions with multiple input values. dataData driving allows one script to test application functionality with many sets of data. Automated data driven testing frees you to perform more tests, thus increasing test coverage. Speed, repeatability, free resources to do other kinds of quality control.

Input ParameterInput Parameters allow you to replace a static, recorded value in a step with a dynamic placeholder (parameter), which represents an expandable range of values. Input parameter names and their values are located in QuickTests Data Table. Input parameter values are input into the application from some outside data source.

Steps to Create An Input ParameterTo create an input data table parameter: Select the step in the Keyword View that contains the recorded input value. From the Value column, click on the current value. Click on the parameterize button. The Constant value appears in the Value Configuration Options dialog box.

Set the Parameter ValueIn the VALUE CONFIGURATION OPTIONS dialog, select the Parameter radio button and ensure that Data Table is selected from the drop-down list. dropFrom the Name drop down list, enter a unique column name to create a new column in your data table or choose an existing column name from the data table. Use the default Global data sheet to store values. Enter the values that QTP will input after the test executes.

Supply Data to the ParameterThe design-time table is the central designlocation for storing input parameter values. The number of rows in the data table will cause the same number of test execution iterations to be run. As a default, the design-time data table designis displayed at the bottom of the QuickTest screen. If you want to show or hide the data sheet, click on the icon in the toolbar.

Verify The Test Run

View the Test Results window to verify that each of the rows from the Design Time Data Table was used during the test run. Expand the tree for each iteration (Row#) to view specific information about the execution of the specific row.

Parameterize a CheckpointYou can use parameterized expected values to make your checkpoints dynamic. They Can be set on: An object property in the Object Repository. A checkpoint on a parameterized field.

A Test with Multiple ActionsActions can be divided into logical sections, like the main sections of a transaction, or by specific business processes. When you create a new test, it contains one action. By dividing your tests into multiple actions, you can design more modular and efficient tests.

Types of ActionsThere are two kinds of actions: Regular (Non-reusable) (NonReusable Tests that contain reusable actions can be used: Locally Externally

Insert Call to a New ActionYou can add a new action during or after recording. Select Insert ? New Action from the QuickTest main menu. The Insert New Action window appears. Or use the lego icon on the toolbar to insert new action.

Using Parameterized DataTest data can be passed from one test to another test using the value of an input parameter. This creates a data flow between business processes. The value passed from one business process to another will come from the Data Table. Be aware of any data dependencies that occur within the business process.

Copied, Existing or New Action

After reusable actions are created, they can be called into a Main Calling test in three ways: Call to New Action Call to Copy of Action Call to Existing Action

Set Actions as ReusableCreate a reusable action from the Action properties dialog. Check the checkbox and click OK. A message will appear stating a description of a reusable action.

Call An ActionYou can do number of things with a reusable action, such as: Call it multiple times within a test. Call it from other tests. View the components of the action tree (you cannot modify them except in the original script) Insert a call to an external action (the action is inserted in read-only format) readas local editable copy use the (read only) data from the original action Insert copies of non-reusable actions noninto your test, but you cannot insert calls to non-reusable actions. non-

One Action used Many Times

Rather than recording the login process three times in three separate tests, and enhancing this part of the script (with checkpoints and parameterization) separately for each test, you can create an action that logs into the application in one test.

Best PracticeInserting calls to existing actions makes it easier to maintain our tests; when an object or procedure in your application changes. It only needs to be updated one time, in the original action.

Set Actions as Reusable

Create a reusable action from the Action properties dialog. Check the checkbox and click OK. A message will appear stating a description of a reusable action.

On Action Two Names

Use the Action Properties General tab to modify the default label. This makes the test easier for others to understand when viewing the test from the Keyword View tree. RightRight-Click on Action and enter a logical name for the business process.

External Action Properties

An external action is a reusable action created in another test. The external action is inserted into the calling test in a read-only format. readData from the external actions data sheet can be imported as a local, editable copy or kept as read only. If read-only, the data can only be modified from the original test. readAfter a reusable action is called, you will see the parameters contained in each test appear in the Global or Local sheet depending on where you stored them in the original test.

Action Run Settings

Since there are two (or more) tests running, one right after another, you may need to specify the iteration for each separately. To affect the run settings for a particular action, set them in the Action Call Properties dialog box. RightRight-Click on the Action label in the Keyword View, and choose Action Call Properties from the list provided.

Defining an Action

The Action Properties dialog box enables you to define options for the stored action. You can modify an action name, add or modify an action description, and set an action as reusable.

Passing Values to a Called Action

You can also define input and output parameters to be used by the action. These settings apply each time the action is called.

Using an Action Parameter

Once parameters have been set in Action Properties, you can tell QuickTest that the parameter type being used is an Action Parameter.

The Test Flow List

The Test Flow List: - Changes with the addition of a reusable action. - Enables viewing of the action tree for a selected reusable or external action. The test flow appears when a test is recognized as having called actions in your test. An action tree displays all the details of the selected reusable or external action.

Action Data StructureIn the Action data structure, each Action will have its own: Folder with an object repository Local data table sheet Run settings

Multiple Reusable ActionsWhen using multiple, reusable actions, keep the following in mind: Actions can be called or copied from another test. Run settings have to be set per action As a default, all actions in a test use the same shared Object Repository. Parameters and data from the called test are reflected in the calling test An action can be deleted or an action call can be deleted. Position your action calls separately or nest them with other actions.

Delete an Action

Because reusable actions can be used throughout your test or test set, when you delete an action, you must decide to delete a specific occurrence of the action and/or all of its calls.

A different message appear when you are about to delete a non-reusable action. non-

8. Data Table Sheets - Global

The Global Data Sheet: Enables you to create a new column or select an existing column in the Global sheet of the Data Table. Inserts or outputs a value from or to current row of the global data sheet during each global iteration at run-time. run Provides a source of values that can be seen and used by any action.

Data Table Sheets - Local

When a Local Data Sheet is used: The parameters and data will appear with different tabs in the main calling tests Data Table. It allows you to iterate reusable actions independently of any other called actions. You will need to link parameters in the main calling test

9. Recovery ScenariosTo instruct Quick test to recover from unexpected events and errors that occur in the testing environment during the run session. A Recovery scenario consists of a) Trigger Event b) Recovery Operation c) Post Recovery Run Option

Recovery Scenario WizardWe can create the recovery scenario using recovery scenario wizard. Recovery scenario wizard consists of a) Define the trigger event that interrupts the run session b) Specifying the recovery operations required to continue c) Choosing a post recovery test run operation d) Specifying a name and description for the recovery scenario e) Specifying whether to associate the recovery scenario to the current test and / or to all new tests.

Recovery Scenario Wizard

Creating Tests without Object Repository

We can use programmatic descriptions to perform an operation on an object that is not stored in the Object Repository. Types of Programmatic descriptions a) We can list the set of properties and values that describe the object directly in a test statement. e.g: Dialog(name:=Login).WinEdit(attachedtext:=agentname).Setimpetus b) We can add a collection of properties and values to a description object and then enter the description object in the statement. Set myobject=Description.Create() myobject(attachedtext).value:=agentname myobject(html tag).value:=a Dialog(name:=Login).WinEdit (myobject).Setimpetus

QTP: Object Repository, Descriptive Programming and Beyond

10. Enhance TestCases With Descriptive ProgrammingInteract with Test Objects not stored in the Object Repository You can also instruct QT to perform methods on objects without referring to the object repository without referring to the objects logical name. To do this you name. provide QT with a list of properties and values that QT can use to identify the object or objects on which you want to perform a method

Enter Programmatic Descriptions Directly into Test StatementsYou can describe an object directly in a test statement by specifying property : = value pairs describing the object instead of specifying an objects logical name. Syntax:Syntax:TestObject(PropertyName1:=PropertyValue, , PropertyNameX:=PropertyValueX) Where Test Object is test object class PropertyName is PropertyValue i.e. the test object property and its value . Each property:= value pair should be separated by commas and quotation marks. For Example: Window(Text:=Myfile.txt-Notepad).Move 50,50 Window(Text:=Myfile.txtIf you want to use the same programmatic description several times in one test, you may want to assign the object you create to a variable. For Ex:- Set MyWin := Window(Text:=Myfile.txt-Notepad) Ex:Window(Text:=Myfile.txtMyWin.Move 50,50

Contd.Once we have filled the Properties collection with a set of Property objects (properties and values), you Can specify the Properties object in place of a logical name in a test statement.For Ex:- (Instead of Entering) Ex:Window(Error).WInbutton(text:=OK, width:=50).click IF Entered Set MyDescription= Description.Create() MyDescription(text).Value=OK MyDescription(width).Value=50 Window(Error).WinButton(MyDescription).Click

VB Script basics Data Types

VB Script basics Variables & ConstantsDeclaring Variables Naming Restrictions Scope and Lifetime of Variables Assigning Values to Variables Scalar Variables and Array Variables Creating Constants

VB Script basics - Operators

VB Script basics Conditions & LoopingConditional Statements If...Then...Else statement Select Case statement Looping Do...Loop: Loops while or until a condition is true.

While...Wend: Loops while a condition is true. For...Next: Uses a counter to run statements a specified number of times. For each...Next: Repeats a group of statements for each item in a collection or each element of an array.

VB Script basics Functions

Key areas in QTPAbout the script structure Actions (Simple, Nested, External, Re-usable) ReParameterization (Different Types) Checkpoints (Programmatic Methodology) Descriptive programming Adv. Synchronization points Exception Handling

About the script structure

Actions (Simple, Nested, External, Re-usable) ReStandalone Actions Nested Actions Integration of Actions (Call from One Action to other) Driver Action (Main Action) ReRe-usable Actions External Call for Actions

ParameterizationClassifications of Parameterization Test and Action Parameters Data Table (Global & Action Specific) Environment variables Random Number

Types of CheckpointsStandard Checkpoint Image Checkpoint Table Checkpoint Page checkpoint Checks values of an objects properties Checks the property values of an image Checks information in a table Checks the characteristics of a Web page Check that a radio button is selected. Check that the image source file is correct. Check that the value in a table cell is correct. Check how long a Web page takes to load or if a Web page contains broken links. Check whether the expected text string is displayed in the expected location on a Web page or dialog box Check that a Web page (or any portion of it) is displayed as expected.

Text / Text Area Checkpoint

Checks that a text string is displayed in the appropriate place in a Web page or application window Checks an area of a Web page or application after capturing it as a bitmap

Bitmap Checkpoint

Cont.Database Checkpoint Checks the contents of databases accessed by an application or Web site Identifies areas of a Web site to check for Section 508 compliancy Checks the data content of XML documents Check that the value in a database query is correct. Check if the images on a Web page include ALT properties, required by the W3C Web Content Accessibility Guidelines. Note: XML file checkpoints are used to check a specified XML file; XML application checkpoints are used to check an XML document within a Web page.

Accessibility Checkpoint

XML Checkpoint

Descriptive Programming SamplesDescriptive programming

Entering Programmatic Descriptions Directly into Statements Browser("Mercury Tours").Page("Title:=Mercury Tours").WebEdit("Name:=Author", "Index:=3").Set "Mark Twain" Using Description Objects for Programmatic Descriptions Set MyDescription = Description.Create() MyDescription("text").Value = "OK" MyDescription("width").Value = 50 Window("Error").WinButton(MyDescription).Click

Adv. Synchronization Points

Using tool menu options Wait property Programmatically Wait & exist

Exception HandlingRecovery Scenario Concepts Recovery Process Trigger Events Recovery Operation PostPost-recovery Operation

Sample Script QTP uncti ns

'sample 1 - Getting all the items fr m the combobox from My_Cnt = Window(" light Reservation").WinComboBox(" ly rom:").GetItemsCount msgbox My_Cnt or i = 1 to My_Cnt ' the combobox item index will start from zero. My_item = Window(" light Reservation").WinComboBox(" ly rom:").GetItem(irom:").GetItem(i-1) Msgbox My_item Next 'sample 2 - Getting the entire content of the combobox Var_Content = Window(" light Reservation").WinComboBox(" ly rom:").GetContent Msgbox Var_Content

Sample Script QTP Functions'sample 3 - Selecting an item from the combo - Using Index Window("Flight Reservation").WinComboBox("Fly From:").Select(5) 'sample 4 - Selecting an item from the combo - Using Value Window("Flight Reservation").WinComboBox("Fly From:").Select("London") 'sample 5 - Selecting an item from the combo - Using Variable Var_Item = "Zurich" Window("Flight Reservation").WinComboBox("Fly From:").Select(Var_Item) 'sample 6 - Getting the value of selected item Var_Sel = Window("Flight Reservation").WinComboBox("Fly From:").GetSelection Msgbox Var_Sel

Sample Script QTP Functions' Some FUM's (Frequently Used Methods) 'GetROProperty Var_Text = Window("Flight Reservation").WinEdit("Name:").GetROProperty("AttachedText") Msgbox Var_Text Var_Enab = Window("Flight Reservation").WinEdit("Name:").GetROProperty("Enabled") Msgbox Var_Enab 'Exist If Window("Flight Reservation").WinEdit("Name:").Exist(5) Then Msgbox "The Editbox exists" Else Msgbox "The Editbox does not exist" End if

Object Repository vs. Descriptive Programming what to use?There really is no best way Use 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 repository Highlight in Application feature is great tool to walk the object tree No need to modify the script when object properties changes Easy to identify objects in AUT by Object Logical names Can be created independently from scripts CONS: Additional layer to maintain Unnecessary objects can be created Multiple users cannot concurrently save/write to the shared OR It wont eliminate the need for Descriptive Programming in most of cases

DP Pros and ConsPROS: Its a white box Compatible with different QTP versions Code portability is high Easy to mass update CONS: Lower Code Readability and requires more comments, like what object is accessed Potentially 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 Repository

Logical Name Properties

OR: Object identification default properties

Script playback using ORQTP finds the Object in Object Repository using object Logical Name and Object Hierarchy QTP retrieves Test Object properties from OR QTP 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 properties Example: Link Logout Same objects on every page Example: Buttons Next, Back, Cancel, OK Lots of similar objects on one page Example: 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.GetROProperty property refers to the AUT Object property (Run-time) (Run.GetTOproperty/SetToProperty refers to the properties stored in OR .Object. .Object. refers to the AUT Object NATIVE properties/methods

Better names for Object Spy radio-buttons radioRun-Time NATIVE Object Run-Time QTP (Test) Object

Object Run-Time Properties from AUT Run(GetRoProperty)

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

Test Object Properties from OR Set/GetToProperty

Regular Expressions in OR Example: Server independent Page object1. Click on Property value to access RegEx 2. Click RegEx Icon

Regular Expressions in OR

Regular Expressions in OR

RegEx icon

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

Smart Identification (SI) Recording OptionsSI Checkbox

Smart Identification (SI) Run Option

SI Checkbox

Thank YouKuldeep Sharma (185459) Mobile : +919910664553 | www.hcl.in HCL Technologies Ltd. [email protected]