Friday, July 16, 2010

Tutorial 1 - What is QTP?

This tutorial introduces Quick Test Professional , features of QTP as Functional Automation Tool & the concept of ADD-ins




Summary

* Quick Test Professional , popularly know by its acronym QTP is the flagship functional automation testing tool from Mercury Interactive now acquired by HP
* It is an icon based tool, which automates the functional & regression testing of an application
* QTP is easier to use and implement for both technical & non technical testers in comparison to other functional testing tools available.
* Quick Test is the market leader in Functional Automation Tool with over 50% market share
* QTP's Scripting Language is VB Script which is easy to use , understand and program
* Quick Test Professional enables Business Process Testing (BPT)
Supports large pool of software development environments like SAP , Web , Oracle etc.
* The trainings have been recorded using QTP version 9.5 but you may use any higher or lower versions for your learning purposes
* For All Hands On in these trainings, we will be using “Flight Reservation” Application which comes bundled with QTP

Tutorial 2 - First Look Flight Reservation Application

This tutorial introduces Flight Reservation Application which will be used for hands-on for the rest of the tutorials.



Notes:
* Flight Reservation Application comes pre-installed with QTP
* Using Flight Reservation , you can book a flight between two cities, even modify or delete and exisiting booking.
* You may also fax a booking to a customer with your custom signature.
* Flight Reservation has a Reports and Graphs section which helps analyze the ticket selling trends.
* A small number of bookings is pre-populated for any new agent , so that you do not have to create test data.
* The application has been designed to help learn all the features provided by QTP. At times , you may find this application buggy but your focus should not be technical accuracy of the application, but on its use as a tool, to learn various features of QTP.

Tutorial 3 - First Look QTP IDE

This tutorial introduces the Quick Test Professional IDE



Video Transcript with Key Takeaways highlighted

* Without further ado , Lets look into QTP
* To launch QTP, In Start Menu, Choose Programs > Quick Test Professional Folder > Quick Test Professional
* The first time you start QTP, the Add-in Manager dialog box opens.It Displays list of all installed add-in along with license expiry date.
* It is recommended you select only the add-ins required for your particular testing session . Because at times , different add-in interfere with each other degrading object identification and QTP's performance. QTP will remember the add-ins you load so that the next time you open QTP the add-ins you selected in the previous session are selected by default.Also, If you do not want this dialog box to open the next time you start QTP clear the Show on startup check box.Click OK.
* The Start Page describes the new features in this release—including links to more information about these features.It also provides links to Process Guidance, a tool that offers best practices for working with QTP.You can open a document from the list of Recently Used Files,or you can click the buttons in the Welcome! area to open new or existing documents.If you do not want QTP to display the Start Page when you next open QTP ,select the "Don’t show the Start Page window on startup" check box.When you select this option, the Start Page is also automatically hidden for the current QTP session as soon as you open another QTP document.To display the Start Page again, select View > Start.
* Title Bar Displays the name of the active document. If changes have been made since it was last saved, an asterisk (*) is displayed next to the document name in the title bar.
* Menu Bar Displays menus of QTP commands.
Toolbars Contains buttons to assist you in managing your document
Document Tabs Enables you to navigate open documents
* Keyword View Displays test steps in a graphical representation
* Expert View Displays test steps as a VB Script line.
* Active Screen Provides a snapshot of your application as it appeared when you performed a certain step during the recording session.
* Data Table Assists you to parametrize your test.
Test Flow Displays the hierarchy of actions and action calls in the current test, and shows the order in which they are run.
* Below are Tabs For Other Panes.
* You can change the look and feel of the main QTP window, as required
* In the QTP window, select View > Window Theme, and then select the way the window should appear from the list of available themes.
* You can move the QTP window panes to suit your own personal preferences.Say we want to Move the Test Flow Pane .In the QTP window, drag the title bar of the Test Flow Pane.As you drag the pane, markers are displayed in the active pane and on each edge of the QTP window.Drag the Test Flow and hold the cursor over the various markers.A shaded area is displayed, indicating the new location of the pane.Lets move it to Right. Release the mouse button.The Test Flow Pane snaps into place and is displayed as a new pane in the shaded area.
That’s all to the QTP IDE

Tutorial 4 - HP Quick Test Professional

This tutorial identifies the TEST STEPS that need to be automated for your First Test Script using QTP



Video Transcript with Key Takeaways highlighted

* Now, Lets Record Our First Script.For Our Application Under Test i.e. Flight Reservation - lets validate a simple test scenario out of possible many
The Scenario Would Be"Check that user successfully logs in to the application on inputting valid Agent Name & Password"
Test Steps required to validate this scenario would be
Step 1) Open Flight Reservation Application
Step 2) Enter Valid Agent Name
Step 3) Enter Valid Password
Step 4) Press Ok
Step 5) Close Application After Successful Login.
Lets automate these 5 steps in QTP

Tutorial 5 - Record and Run Settings QTP

This tutorial introduces the Record & Run settings & It demonstrates , how to record a script in QTP



Video Transcript with Key Takeaways highlighted

* In QTP click the record button.The Record and Run settings Dialog Box Opens.This box opens automatically each time you begin recording a new test.
Record & Run settings shows a tabs corresponding to add-ins installed and loaded for your test.So, for example if you have SAP Add-in Installed and loaded you will see a SAP tab.
The Windows Application tab is always available and be used for environments, such as Visual Basic, ActiveX, and terminal emulators.
* For any Environment, the Record and Run settings can be classified into two generic groups
1) Record & Run on ANY window belonging to that particular environment
2) Record & Run on a SPECIFIC window belonging to that particular environment - which is the recommended Option
For the time being , lets stick to default settings .Once settings are done , QTP remembers and uses the same settings for additional record sessions on the same test, unless you manually open the Record and Run Settings dialog box to modify the settings.
Click okay
* QTP Starts Recoding Mode
Step # 1 is to Open Flight Reservation Application
Click Start Menu > Program Files > Quick Test Professional > Sample Applications > Flight Reservation
Step # 2 Enter a Valid Agent Name greater than 4 characters say Guru
Step # 3 Enter a Valid Password which is by default MERCURY
Step # 4 Click Okay
Step # 5 Check that the Flight Reservation opens successfully which it is . Click the close button.
* All the 5 steps are now recorded
In QTP , Stop recording
* Save the script as "LogIn"

Tutorial 6 - All about Object Identification

This tutorial demonstrates how QTP identifies an on - screen GUI Object and the concept of QTP's Test Object Model



Video Transcript with Key Takeaways highlighted

* QTP also uses a "human" like technology for object identification
* During Record Time QTP tries to learn properties of a GUI object on which operation is performed.
* During Run-Time QTP compares the stored object properties with actual properties of object available on screen and uniquely identifies an object independent of its location on screen
* The stored object and together with its properties is called TEST Object
* During Run-Time, the actual object available on the application under test is called Run-Time Object
* This is Quick Tests "Test Object Model"
* Information about the Test Objects is stored in Object Repository
* Add-ins help in instructing Quick Test

Tutorial 7 - Expert View in QTP

This tutorial interprets the Expert View and gives its Syntax




Video Transcript with Key Takeaways highlighted

* In the Expert View , each line represents a Test Step in VB Script
* To understand expert view better , lets analyze Step # 2 from our TEST recorded earlier
* An Object's Name is displayed in parentheses following the Object Type.Here the Object Name is Login and * Object Type is Dialog
* Objects in Object Hierarchy are separated by a "dot".Here Dialog and WinEdit are fall in the same Object Hierarchy
* Just to put things in perspective, Object Hierarchy is Object Oriented Concept where set of objects that are grouped together in a parent-child relationship.In our case Dialog Box is the Parent Object and WinEdit is the Child Object
* The Operation performed on the object is always displayed at the end of the statement followed by any values associated with the operation.Here the word "Guru" is inserted in the AgentName Edit Box using the Set Method
* Syntax for a statement in expert view is GUI object on which the operation is performed along with its complete hierarchy followed by the Operation on the Object and value associated with that Operation

Tutorial 8 - Compare Keyword view and Export view in QTP

This tutorial interprets the Keyword View and compares the Expert & Keyword View




Video Transcript with Key Takeaways highlighted

* The Keyword View is comprised of a table-like view where
* Each step is a separate row in the table and
* Each column represents different parts of the steps.
* Item Column contains the item on which you want to perform the step. This column uses icons displays the hierarchy of the GUI object on which operation is performed
* Operation Column contains the operation to be performed on the item.
* Value Column contains the argument values for the selected operation,
* QTP automatically documents each step for easy understanding in the Documentation Column
* These 4 columns are default but you can also use assignment & comment columns in Keyword View
* That’s all to the Keyword View
* Lets Compare the Keyword and Expert View using Step no 2 from our script. You will observe that the same object hierarchy is displayed in both Expert & Keyword Views and they map to the same operation and argument value.
* Essentially , Keyword & Expert view contain the same data but arranged in different format.
* In fact you can perform all operations like create , modifying a step . using the Keyword View but to gain mastery over the tool we will restrict ourselves to the Expert View

Tutorial 9 - QTP

This tutorial interprets the script that was recorded in earlier tutorials




Video Transcript with Key Takeaways highlighted

* Now , Lets go ahead and understand our recorded test.
* The first step is the SystemUtil.Run Command which is used by default by QTP to open a application.So during recording , using the Windows Start Menu , when we finally navigated to the "Flight Reservation" application QTP identified the location of its executable file and inserted the System.Util Command to Open it.
* Step No 2 is Setting Agent Name as Guru as shown in the Active Screen
* Step no 3 is Pressing the Tab key on keyboard to bring Focus from Agent Name Field To Password Field , which is exactly this step. Human users need to use tab or click operations to focus on a particular object on screen.. On the other hand , QTP can directly identify an object using object properties and does not required these "maneuvering" operations. We can delete this step , as QTP will still be able to set the password field without this operation
* Next Step is Setting the Password as Mercury. QTP automatically encrypts passwords entered while recording to avoid security breaches. This value can not be decrypted ie. There is no way to recover the original value using this cryptic data. You can explicitly encrypt a password using the Password Encoder Tool. For our learning purposes , we will use the password in its raw form. And the operation will also change to Set
* Next Step is clicking the okay button
* Next Step is closing the application after successful log on
* So the 5 steps mentioned in our test script are recorded in QTP

Tutorial 10 - What is Replay in QTP?

This tutorial introduces the concept of REPLAY . It demonstrates the Run Settings available in Quick Test



Video Transcript with Key Takeaways highlighted

* Now , lets go ahead and REPLAY the script to ensure the test steps have recorded correctly.
* Click the Run Button.
* The Run Dialog Box Opens which enables you to specify the location in which you want to save the run session results.
* This option displays the default path and folder name in which results are stored. By default results are stored in Test Folder .A new sub-folder is created with the name RESn .The number n is incremented for each run.
* You may accept the default settings or specify a folder of your choice
* Temporary run results folder options saves the run results in a temporary folder. This option overwrites any results previously saved in this folder.
* Its recommended that while developing your test script choose the Temporary option and once the script is baseline you can use the new folder option
* In our case we will use the temporary option and click okay. QTP enters the run mode
and will start executing steps one by one.
* In QTP window you can see a yellow marker pointing at the step which is currently being executed.
* During Replay the script performed exactly the same 5 steps that were recorded which signifies that there were no errors in recording.
* Test Results are also shown

Tutorial 11 - Test Results in QTP

This tutorial demonstrates the various features available in the Test Results generated by QTP



Video Transcript with Key Takeaways highlighted

* Lets understand the Test Results generated by QTP
* Right Hand Side shows Test Results Summary
* Left Hand Side is Test Results Tree - an icon-based view of the test steps that were performed while the test was running. Similar to the test tree in Keyword View
* If you select a step in the tree , the right panel gives it complete details
* This Apart
* You can capture Movie / Screenshots of entire Test Run using Tools > Options > Run Tab
* In our case this movie was recorded and , screen shots were captured
* You can print/export full/part of results in HTML , Word or PDF format.
* You can exports the results to Quality Center
* You can change the format of Results by using Results.xml and creating a XSL

Tutorial 12 - All about parameters in QTP

This tutorial demonstrates parameterization



Video Transcript with Key Takeaways highlighted

* You may be wondering why take the Herculean effort to automate this simple scenario
* Check that user successfully logs in to the application on inputting valid Agent Name & Password
* The need becomes obvious if we extend the scope of the scenario to include a Combination of valid ALPHANUMERIC Agent Name & Password
* In this case , the Test Steps Will Remain the Same. But we will have more combinations of Data To TEST. We will restrict to just 3 of possible 8 combinations
* To achieve this you can either copy the six steps and give different data values which is in fact * something you would do manually. Or you can use Parameterization
* The easiest way to parameterize an argument , in our case Guru is in Keyword view , Click the Parameterization Icon
* Value Configuration Dialog Box Opens. Currently the value is set to a Constant. Click on Parameter Radio Button. QTP assigns a default name to these parameter. You can give a name of your choice. Click Okay
* In the Global Sheet , a column with Header "Agent Name" and value Guru is created. You can enter more values for this parameter
* Likewise you can also parameterize the argument Password and enter different test data sets.
* What this Data sheet means is QTP will iterate the same 6 steps that we have recorded 3 times. During * first iteration it will use the data in the first row. During second it will use data in the second row and so on
* Now lets run the script. This is the first iteration. This is the second iteration
* In the status bar QTP gives information of the row, it is currently using as test data and highlights the * corresponding row in the data sheet. The results will show summary of the 3 iterations.
* A brief recap of parameterization
* Parameterization allows us to pick different values at run time.
* It Reduces Time and Effort.
* Usage of Data Drivers allow us to use the same data for various input boxes. Data Drivers is feature provided by QTP which shows all the constants that could be parameterized in one single window

Tutorial 13 - What are the standard checkpoints in QTP?

This tutorial introduces Checkpoints



Video Transcript with Key Takeaways highlighted

* You may have notice that results generated for our test script has no Pass/ Fail Status without which our automation is incomplete
* The expected TEST RESULT for our scenario should be - Flight Reservation Window
* which is this screen should appear after entering valid username and password. To accomplish this we will need to record an additional step # 6 which is Check Flight Reservation Window is Displayed..
* Automation of this verification step can be achieved using Checkpoints- A checkpoint is a verification point that compares the current value with the expected value for specified properties of an Object. If they current and expected value match it generates a PASS status otherwise FAIL status
* Lets go ahead and record step # 6
* To add a checkpoint , right click on the step # 5 after which checkpoint needs to be inserted .Choose Insert Standard Checkpoint. Checkpoint Properties Dialog Box Opens.
* QTP assigns a default name to checkpoint. You can input your preferred name
* The table shows all the recorded properties and their corresponding values for the object. The Selection mark indicates that these properties will be checked
* ABC icon indicated that the property values are a constant. If you parameterize any of the selected properties the icon changes correspondingly
* Lets stick to the default and insert the statement after the current step. Click okay
* A check statement with checkpoint name is inserted at line # 6.Lets replay the script
* The script gives a Run-Time Error
Well this is a common source of error for beginners and happens because at step # 5 , QTP closes the Flight * Reservation Screen and when the execution reaches step # 6 there is no Flight Reservation Screen Object available to very its properties. You need to ensure , that the object which are verifying is available while QTP executes the Checkpoint Step
* This error can be rectified by changing the sequence of Tests Steps. You need to switch
* Step 5 & step 6 . In the new scenario step 5 is verify the Flight Reservation Window Exists and step 6 is to Close the application
* In QTP , you just need to cut step # 6 and paste it at location of step # 5.Lets replay the script again. * The Script passes and the results tree gives the checkpoint values that were compared. That's all to standard checkpoints
* A recap of checkpoints-
* There are many types of checkpoints and the most generic is the standard checkpoint.
* Standard checkpoints compare the expected values of object properties captured during recording to the object's current values during a run session

Tutorial 14 - Types of checkpoints in QTP

This tutorial demonstrates different types of Checkpoints in Quick Test Professional




points to remember

A Checkpoint is a confirmation or verification point in which the value of some property which is expected at a particular step is compared with the actual value which is displayed in the application. Based on the expected values Checkpoints are classified as follows

* Page Checkpoint : A Standard Checkpoint created for a web page can be called a Page Checkpoint. It is used to check total number of links & images on a web page. Page Checkpoints can be used to check Load Time i.e. time taken to load a web page.
Bitmap Checkpoint helps a user in checking the bitmap of an image or a full web page. It does a pixel by pixel comparison between actual and expected images.
* Image Checkpoint enable you to check properties like source file location of a web image. Unlike , Bitmap Checkpoint you can not check pixels(bitmaps) using image checkpoint.
* Text Checkpoint is Used to check expected text in a web-page or application. This text could be from a specific region of the application or a small portion of text displayed
* Accessibility Checkpoints verifies compliance with World Wide Web Consortium (W3C) instructions and guidelines for * Web-based technology and information systems. These Guidelines make it easy for disabled to access the web.
* Database Checkpoints create a query during record time and database values are stored as expected values. Same query is executed during run time and actual & expected values are compared.
In Table Checkpoint , you dynamically can check the contents of cells of a table (grid) appearing in your * environment. You can also check various table properties like row height , cell width and so on. Table Checkpoint is similar to Database Checkpoint
* Using XML Checkpoints you can verify XML Data ,XML Schema, XML Data

Tutorial 15 - How to insert output values in QTP?

This tutorial demonstrates the concept of Output values in Quick Test Professional



points to remember

An output value step ,is a step in which a object property value is captured at a specific point in your test and stored at a desired location. The stored values can be used as input at a different points in test script. Multiple properties of an object can be selected and outputted.

Types of Output Values

* Standard output value
* Text /Text Area output value
* Data base output value
* Xml output value (from application/resources)

Tutorial 16 - Conditional Loops in QTP

This tutorial demonstrates advanced coding in QTP using if and else loop



Video Transcript with Key Takeaways highlighted

* From your testing background you will certainly infer that a more accurate Test scenario would be * Validate the Login Functionality of Flight Reservation which should have two sub scenarios
* Check that user successfully logs in to the application on inputting a COMBINATION OF valid ALPHANUMERIC Agent Name & Password
* Check that user log on fails on inputting INVALID Agent Name & Password
* More so , a robut automation script should be able to accept and handle both valid and invalid login details
* We have the sub-scenarios already recorded So the challenge is to integrate them.
* You May observe for both the scripts - STEPS ,Launch Flight Reservation Application, Enter Agent Name ,Enter Password ,Click OK ,while steps Checkpoint ,,Close Flight Reservation Window, for positive scenario, and steps ,Output Error Information ,Close Error Info Window ,Close Login Dialog Box, for negative scenario are different
* There are many ways to integrate them and once of the ways ,is to use if and else loop and check whether error information screen exists after entering the agent name and password. if yes do the steps for negative scenario, if no do the steps for positive scenario
* In QTP Window, After step # 4,Add a step if else loop, The check condition is whether error information screen exists. Copy this step and paste it as check condition.
* Delete the Click Operation. And replace it with Exists method. This method is applicable to almost all objects and checks whether the particular objects exists on screen or not
* If result is true do the negative scenario steps. I will cut and paste the steps inside the loop
* Copy the steps from the positive scenario and paste it in the else loop. Lets run the test for one valid and one invalid login credentials. The test Runs successfully .Note is you saved the tests in the order mentioned in the tutorials
* PositiveLogon to NegativeLogon and Negative Logon to Combined you should have no problem running the test.
* Apart from if and else you can also use - if elseif., while wend.,do case ,for Loops. as per your requirements

Tutorial 17 - How to user Report.Report Event in QTP

This tutorial demonstrates the use of function Reporter.Report Event and Results Formatting.The tutorial will ask you to develop a script. To maximise your learning , please do complete the scripting exercise.



points to remember about QTPs Test Results Formatting

* You can use Reporter.ReportEvent to report custom test steps in QTP's test results tree
Syntax -Reporter.ReportEvent EventStatus, ReportStepName, Details [, ImageFilePath]
* Event Status can have values
* 0 or micPass sends a pass status to test result window
* 1 or micFail sends a pass status to test result window
* 2 or micDone sends a message to test result window without affecting the Pass/Fail status
* 3 or micWarning sends a warning message to the result window
* When test cases are executed using automation tools it may be difficult for certain users to understand the test results You can use results.xml to create an xsl which will present the test results as per your preferences
* You can use VBScript Library functions to store the results in xls or a text file.

Tutorial 18 - Complete Guide on Actions in QTP

This tutorial demonstrates Actions. It uses the vanilla Test Script created in previous tutorials with 5 steps to log in into Flight Reservation.This tutorial is the longest in all QTP tutorials and its recommended you take notes while viewing it.



key takeaways:

* Actions help divide your test into logical units or Business Processes
* Actions help create a script which is more modular and efficient.
* When a script is newly created it consists of only one action .A script can consist of one or more Actions .
* There two types of Actions 1)Reusable Actions & 2) Non-Reusable Actions
* Reusable Action can be used in other Tests. They can be used in the same Test Script multiple times.
* Non reusable Action can not be used in other Tests. They can be called in the same script only once
* You can split an existing action in two ways 1) Independent of each other which splits the selected action into two sibling actions 2) Nested Action which splits the selected action into a parent action whose last step calls the second, child action
Q* TP provides 2 type of datasheets 1) Global & 2) Local
* GLOBAL Datasheet : It is Unique for the entire test. Any Action can access and write data into Global Datasheet. Sheet is named “GLOBAL”
* LOCAL Datasheet : Equal to number of Actions in the sheet. An Action can read and write data into its own local Datasheet only. Sheet name = “ACTION NAME”
* There are two methods to import Actions into a Test 1) Call to Copy & 2) Call to Existing.
* Call to COPY of an Action : When you make a Copy of an Action , the action is copied in its entirety, including checkpoints, parameterization, and the corresponding action tab in the Data Table into the calling test . When you insert a copy of an existing action, you can make changes to the copied action, and your changes will not affect nor be affected by any other test. You can insert copies of both reusable and non-reusable actions
* Call to an EXISTING Action : Calls to actions are read-only in the calling test. They can only be modified in the test in which they were created. Enables you to use the same action in several tests and makes it easy to maintain tests. You can make calls to only “Reusable” actions.
* You can change the action iteration frequency by selecting Action Call Properties > Run Tab

Tutorial 19 - QTP Object Identification

This tutorial demonstrates how Object Identification works in QTP.Before you begin , you must know an object property and its value is called Object Description used to identify the corresponding Object.For example , for a WebButton property "name" and its value "Login" together can be termed as Object Description for that Web Button.The term Unique Description implies finding typical Object Description for fast object identification.



Video Transcript with Key Takeaways highlighted

* QTP stores Object and its properties in Object Repository to identify them during run-time.
* An Object could have large number of properties associated with it. For example in Web Environment a Button could have the following properties associated.
* If QTP will try and remember all the available properties for an object, size of Object Repository will bloat and script execution time will increase drastically
* To avoid this, QTP by default , does not store all the properties of an object but a limited no of typical properties for an object which helps in its unique identification.
* These settings are store in Object Identification
* In QTP in Tools Menu , select Object Identification
* In Object Identification Dialog Box you can see a drop down of all the environments installed and loaded.
* You can select an environment and QTP auto populates list of all the supported objects belonging to that environment. On the right QTP lists the properties that will be stored for the object
* The list is divided into 2 columns 1) Mandatory & 2) Assistive
* 1) Mandatory properties will be stored by default for that object
* 2) In case during record time of script QTP can NOT create a unique description of the object it will store the assistive properties
* To understand this better consider the example of an Image. QTP will store value of alt ,html tag, image type, properties mandatory even if it can uniquely identity it using the alt property alone.
* In case it can not create unique description using mandatory property ,QTP will store assistive property. In this case QTP will store the class property .
* If this property helps create a unique description of the object, QTP will not store file name, height property. If class property is not sufficient to create unique description, QTP will store file name property . If file name property creates a unique description QTP will not store height property and so on.
* Suppose during Record Time, QTP has only stored class property
* At Run - time ,QTP will forget the distinction between mandatory and assistive properties and compare all the recorded properties.
* Even if any one of the properties does not match its stored value , Script fails

Tutorial 20 - All about Smart Identification in QTP

This tutorial demonstrates SMART Identification process in QTP.For the first time, the tutorial makes use of a Web Environment.



points to remember

* If the usual object identification process fails , QTP triggers Smart Identification , which is more flexible mechanism for identifying objects provided it is enabled in Object Identification settings.
* Smart Identification uses two categories of properties 1) Base Filter Properties & 2) Optional Filter Properties
* Base Filter Properties. It contains the most fundamental properties of a particular test object class; those whose values cannot be changed without changing the essence of the original object
* Optional Filter Properties. Other properties that can help identify objects
* Quick Test "forgets" the learned test object description and creates a new object candidate list containing the objects that match all of the properties defined in the Base Filter Properties list.
* QTP the Uses Base Filter Property to reduce the Object Candidate list
* The idea is to narrow down only one object matching the some or all of the saved description properties
* If smart identification is invoked during a test run ,in the test results tree a warning message is generated indicating smart identification was invoked and a smart identification step is inserted.

Tutorial 21 - Object Property Modification

This tutorial uses Object Property Modification to address the property change issue faced in Tutorial 20 (smart identification).It is recommeded you go through Tutorial 20 before taking this tutorial



Video Transcript with Key Takeaways highlighted

* You may have observe that smart identification slows down script execution which is not desirable
* To avoid smart identification , we can change the default object identification properties
* In QTP , Object Identification , lets remove "name" from the mandatory properties and replace it with "html id" to make our test independent of name changes
* You can re-record the same steps for the script
* Now if you change the name from "Submit" to "Login" and run the script the script executes without any smart identification
* Similarly , in your application under test if any of the mandatory or assistive properties change frequently for an object you can replace it with some other suitable property to enable faster script execution
* Property tweaking is an experience game field and you will pick it up as you age with the tool

Tutorial 22 - Ordinal Identifiers

This tutorial introduces Ordinal Identifiers .It is recommended you complete Tutorials 19 , 20 & 21 before taking this tutorial.




points to note:

If mandatory 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
By default, an ordinal identifier type exists for each test object class.
In the Object Identification Window, you can modify the default Ordinal Identifier for an Object


There 3 types of Ordinal Identifiers
* 1) Index based
* 2) Location based
* 3) Creation Time


Index Based

* When using Index based ordinal identifier, while recording , QTP will assign a value to INDEX property of an object
* The value is based on the order in which the object appears within the source code.
* The first occurrence has value 0
* Index property values are object-specific.
* Therefore, if you use Index:=3 to describe a WebEdit test object, Quick Test searches for the fourth WebEdit object on the page.
* Likewise , you use Index:=1 to describe a WebButton test object, Quick Test searches for the third WebButton object on the page



Location Based
* When using location based ordinal identifier, while recording , QTP will assign a value to LOCATION property of an object 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 identical properties.
* The first occurrence of the object is 0.
* Values are assigned in columns from top to bottom, and left to right.


Creation Time
* When using creation time ordinal identifier, while recording , QTP will assign a value to CreationTime property of an WebBrowser
* The Identifier is only available for the Web Environment
* This value indicates the order in which the browser was opened relative to other open browsers.
* The first browser that opens while recording receives the value CreationTime=0 and succeeding browsers are give values 1 , 2 , 3 … an so on

Tutorial 23 - Local Per-Action Repository in QTP

This tutorial introduces the different types of Object Repositories and discusses Local Object Repository in detail



points to note:

* Local Object Repository is the default object repository
* It is specific to actions and can be used only for a particular action
* Local Object Repository is preferable when application is not dynamic with respect to time
* Local Object Repository cannot be reused
* You can perform many a operations in the local object repository such as -

* Highlight an object stored in repository on the application under test
* Check whether a particular object in your AUT is stored in the Object Repository
* Cut , Copy , Paste , Modify and Delete Objects
* In case you have accidentally modified the value of a property you can update its description from the application using update function.

Tutorial 24 - How to create shared repository in QTP

This tutorial demonstartes Shared Object Repository in detail



Summary:

* Global or Shared Object Repository is preferable when application is dynamic and object description change frequently
* Between Shared and local object repository , shared object repository is more commonly used in automation projects
* But it has maintenance and administration overheads as compared to local object repository.

To create and use a shared object repository you need to perform three broad steps
* 1) Creating a Shared Object Repository
* 2) Associating a Shared Object Repository
* 3) Editing a Shared Object Repository

Lets look at them one at a time

1) Creating a Shared Object Repository
* All repositories are local by default . To create a Shared Object Repository, in the Object Repository Dialog Box , Click File > Export Local Objects
* Repository files have an extension .tsr .Give a suitable name say "guru99" and save
* The Shared Repository File is now created

2)Associating a Shared Object Repository
* Next step is to associate the repository to your test, which enables you to use it
* To associate repository with a test, Click Resources > Associate Repository
* You can select the Repository to associate with Actions available in your test.
* Now you can now use this shared repository to develop your test

3) Editing a Shared Object Repository
* You can use the Object Repository Manager to Edit a Share Repository.
* Select Resources > Object Repository Manager .Open the Object Repository we created "guru99"
* By Default , Repository is opened in Read-only mode. To enable editing click File > Enable Editing
* Once editing is enabled you can all the operations like cut , copy , pate , rename objects etc that you can also do in Object Repository
* Using Object Repository Manager is you can compare two Object Repositories .QTP will give you a static's of what's unique and common in both the repositories
* You can use the Object repository merge tool to merge two repositories into oneT

Tutorial 25 - Guide to develop a script in Export View of QTP

This tutorial demonstartes how you can develop a script directly in EXPERT view in QTP



Video Transcript with Key Takeaways highlighted

* Suppose my objective is to code the following statement directly in keyword view
* Dialog(Login).WinEdit(Agent Name:).Set Guru99
* In QTP screen when I press Cntrl + spacebar ,a list containing of all possible properties , methods is shown
* Also the list shows the objects stored in the object repository
* Select Dialog
* As soon as I open the parentheses , object name login is auto populated , if there are more than one * object for the same object type a list is displayed
* On pressing the . key a list of all the methods for the Dialog object and its child objects are displayed. Select WinEdit
* On inputting the dot operator a list of methods for Winedit box is displayed select SE

Tutorial 26 - Type of Recording Modes

This tutorial demonstrates the 3 types of Recording Modes in QTP



points to remember

QTP supports 3 types of recording modes

* 1) Context Sensitive
* 2)Analog
* 3) Low Level

Context Sensitive Recording mode
* Normal recording mode is also called Context Sensitive Mode
* It is the default mode of recording which takes full advantage of Quick Test Professional's test object model.
* It recognizes objects in application regardless of their location on the screen.
* It records the objects in your application and the operations performed on them

Analog Recording Mode

* In analog recording mode, Quick Test Professional records and tracks every movement of the mouse as you drag the mouse around a screen or window.
* QTP’s Analog recording is captured as Tracks and stored in the directory of your test
* It is useful for recording operations that cannot be recorded at the level of an object. Eg., A signature produced by dragging the mouse
* In Analog mode you can record 1) Record Relative to screen & 2) Relative to window
* When your analog operation are confined to just one window , use relative to window
* When your analog operation involve multiple screens like dragging and dropping an object from one window to other use the screen option

Low Level Mode
* This mode enables you to record on any object in your application, irrespective of QTP recognizes the specific object or the specific operation.
* This mode records at the object level and records all run-time objects as either Window or WinObject test objects..
* It is used when the exact coordinates of the object are important for your tests. A good example would be hashmaps where clicking different sections of a picture takes you to different links
* Used when recording tests in an environment (or on an object) not recognized by QTP
* Low level mode records the x,y coordinates of any clicks

Summary
* Analog recording and low-level recording require more disk space than normal recording mode.
* For both modes , screen positions during the record and run time needs to be identical otherwise script fails
* Hence, Use analog recording or low-level recording only when normal recording mode does not accurately record your operation.
* At times QTP automatically switches to low level mode while recording objects or environments not supported by QTP

Tutorial 27 - All about user defined functions in QTP

This tutorial describes how you could use Functions in QTP



Video Transcript with Key Takeaways highlighted

* If you have segments of code that you need to use several times in your tests, you may want to create a user-defined function. By using user-defined functions, your tests are shorter, and easier to design, read, and maintain
* Your own function libraries, can contain VBScript functions, subroutines, modules etc.
* You need to follow 3 simple steps to use a function from a library in your test
* To create a new function library in QTP
* Select File > New > Function Library. It opens as a new tab in QTP
* Lets a create a very simple function which shows Message Box.So whenever this function is called a message box must be displayed
* You can have mutliple functions defined in the same file.Let's save the function
* A function has an extension .qfl
* Next Step Associate the library with your test
* Click File > Settings > Resources > Associate Function Library.Click Add. Select The Function Library File.Click Okay
* Last step to use the function
* In your test simply call the function. When you run the test as expected Message Box is displayed
* Using COM , DCOM objects you can create very advanced Functions
* Infact, many of the features provided by QTP can be coded using VBScript
* We have seen automation engineers who make it more of a VB project rather than automation project
* Our recommendation is to focus on 100% automation rather than flaunting your VB skills

Tutorial 28 - All about Transanctions in QTP

This tutorial describes how you could use TRANSACTIONS in QTP




Video Transcript with Key Takeaways highlighted

* You can measure how long it takes to run a section of your test by defining transactions.
* You define transactions within your test by enclosing the appropriate sections of the test with start and end transaction statements.
* For example, you may want to note the time taken to book a flight
* In QTP , select the appropriate statement where you want to start your transaction .
* Select Insert Start Transaction.
* Start Transaction Dialog Box opens
* Give the transaction a suitable name, say "Booking Time"
* A start transaction statement is added in the test
* Select the statement where you want to end the transaction
* Click Insert > End Transaction
* End Transaction Dialog Box Opens with the list of all available transactions
* Click Okay. An end transaction statement is added
* Lets runt the test
* * In results , the end transaction statement gives the time taken to insert the order
* Transactions can be inserted anywhere in the script
* There is no limit to the number of transactions that can be added to a test.
* You can also insert a transaction within a transaction

Tutorial 29 - All about Recovery Scenario in QTP

This tutorial demonstrates Recovery Scenarios in QTP



Video Transcript with Key Takeaways highlighted

Using Recovery Scenarios you can instruct QTP to recover from unexpected events and errors that occur in your testing environment during a run session.

Recovery scenario become crucial for large tests, which run unattended and are paused until recovery operation, is performed increasing the test execution time.

There are 6 steps involved in creating a recovery scenario

* 1) In QTP , Select Resources > Recovery Scenario Manager .Create new Scenario
* 2) Specify the Trigger Event. A Trigger Event is an event that interrupts your run session
* 3) Specigy the Recovery Operation which is the corrective action you take when trigger happens
* 4) Specify Post-recovery test run options which specify how to continue the run session after Quick Test Professional has identified the event and performed all of the specified recovery operations.
* 5) Check and verify Summary of the scenario you created.
* 6) Add Recovery Scenario to your test using File > Settings > Recovery.

The test results window show the details of the recovery scenario

Use can also use statements
On Error Resume Next :
On Error Go to 0 :

to handle errors in your script

Tutorial 30 - What is an Optional Step in QTP?

This tutorial describes an OPTIONAL STEP and how it can be used.



Video Transcript with Key Takeaways highlighted

* An optional step is a step that is not necessarily required to successfully complete a run session.
* During a run session, if the object of an optional step does not exist in the application * QTP bypasses this step and continues to run the test
* To set a step as optional in keyword view right click on the step and select Optional Step
* Alternatively, you can directly write the keyword "OptionalStep" preceding a statement to make it optional

Tutorial 31 - Guide to Object Sopy | GetROProperty, GetTOProperty & SetTOPropert

This tutorial demonstrates OBJECT SPY.Object Spy can help determine useful properties and methods associated with an object in your environment .The tutorials also describes GetROProperty, GetTOProperty & SetTOProperty



points to remember

GetRoProperty

* GetRoProperty – is an in-built method used to retrieve runtime value of an object property.
* There are 4 steps involved in using the GetRoProperty
* Step 1) Record the Object on which you want to use the GetRoProperty in Object Repository
* Step 2) For the recorded object identify the run-time property which could be used. You may use Object Spy.
* Step 3) Use GetRoProperty method to retrieve the identified Run-time property and store the value in a variable
* Step 4) Use this value for further deductions

SetToProperty & GetToProperty
* Consider a Web Button stored in the Object Repository
* When the test is run QTP creates a copy of this object called Test Object and compares it with the Run Time Object
* Using GetToProperty you can retrieve the value of a property of Test Object
* Using SetToProperty you can change the property value of a Test Object
* When the test is completed, this test object is discarded and so are any modifications you made in the object properties using the SetToProperty
* When the test is re-run, a new copy of the test object is created with original property values stored in the object repository
* You can consider using GetToProperty and SetToProperty when your test script has multiple lines of codes and your environment is sporadic
* For a note ,there is no SetRoProperty

Object Spy:
* Object spy is feature in QTP using which you can view both the test and run-time object properties and methods.
* It also gives the syntax for a selected method.
* Object Spy gives the complete hierarchy of the object you have selected

Tutorial 32 - Descriptive Programming

This is the 1st part of a two part tutorial for Descriptive Programming. It introduces Descriptive Programming and its two type viz. static and dynamic.



Video Transcript with Key Takeaways Highlighted:

* To understand the concept of descriptive programming lets understand the significance of an objects name in QTP
* An object name is simply used to map an object in script with its description in object repository.
* Meaning if I change the object name here to ABC and correspondingly change the object name in script to ABC the script will still work fine.
* Consider this statement, which sets the Agent Name as Guru99. Let us do an experiment..Let's delete the Object Description of Agent Name Win Edit Box from the Object Repository.
* If I run the test again it will fail since it can not recognize the object. Lets examine the reason why the script is failing
* During Run Time, QTP identifies the operation that is performed on WinEdit box and the Object Description in Object Repository is stored as Agent Name
* It uses this name to track the object in object repository. For a parent you cannot have two child objects with the same name. Hence, QTP uniquely maps the object in the repository
* It then uses the stored description in the Object Repository and replaces the name with the description. It then uses this statement to identify the object in the application under test
* Since in our case we had deleted this object description all together the script fails
* But what if instead of QTP replacing the object description, you as a tester directly specify the object descriptions in your script. This is nothing but "Descriptive Programming"
* You can use Descriptive programming in two ways 1) Static 2) Dynamic
* Lets look at Static First. In Static Method , for object identification in the following format property:=values , you mention an objects property ,and its corresponding values separated by a colon and equal to sign. This format is called property value pair and is enclosed in inverted commas
* If your object uses multiple descriptions for identification, you can specify those using commas
* So in our case the description for Agent Name becomes "nativeclass:=Edit", "attached text:=Agent Name:"
* Next Step is to Replace Object Name with above description. In QTP , lets do the replacement and run the test. It runs fine . In the test results the Agent Name object is enclosed in parentheses indicating that Descriptive Programming was used in its identification. * This is the static method
* The second method of doing the same action is using Dynamic Descriptive programming
* In case your script uses the descriptive programming object candidate multiple times, * it will be very tiresome to specify all the property value pairs for each statement
* In such cases you can make use of Description Class provided by QTP
* Syntax for creating an description object is
Set MyDescription = Description.Create();
MyDescription("property").Value = "property-value";
This is the Dynamic Method

Tutorial 33 - Descriptive Programming Practical Application

This is the 2nd part of a two part tutorial for Descriptive Programming. It describes practical application of Descriptive Programming .It makes use of ChildObjects() a method used to find all Child Objects for a Parent object.



Video Transcript with Key Takeaways highlighted

* The million dollar question is why use DP when the Object Identification process is handled by QTP
* Suppose you are assigned to test a job portal. You enter a search query into the portal and
your test expects you to select all available jobs .and click the apply job
But the no of jobs reflected will depend on the search query and jobs available at time of script execution but there is no way to predict in advance the no of jobs that would be reflected
* In such cases, you can use descriptive programming. Even though you do not know the number and names of the checkboxes you do know the class for the objects as "WebCheckBox"
* You can use the ChildObject method to return objects belonging to a particular parent
* A line of code like - Set allObjects = Browser("Jobs").Page("QTP").ChildObjects()
Will return all child objects for this page.
* But we want only WebCheckBox objects.To do so we can create a filter creation object and set its property as WebcheckBox and pass this filter as an argument for the ChildObjects method
* In this case only the checkboxes are returned.
* Next you can write a code like this which access the entire collection of checkboxes starting from zero and sets all checkboxes ON.
* Next you can click apply button to complete the test
* You can also use Descriptive Programming to run objects which are difficult to record like Auto-Hide Panels, Objects with changing hierarchies, Nested Inner Objects ,Sub-menus.
* You can also do advanced string manipulations using descriptive programming
* In conjunction with index property, descriptive programming could be very useful in identifying difficult objects.
* If you use programmatic description for an object in object hierarchy you will need to use description programming for succeeding child objects
* For example, for page object descriptive programming was used but for succeeding child object WinEdit Object Repository is used which is incorrect
* On the contrary here for both Page and WinEdit descriptive programming is used which is correct
South Beach Smoke E-Cigarette - The Better Smoking Choice