SlideShare une entreprise Scribd logo
1  sur  127
Télécharger pour lire hors ligne
Amarendra Kumar Kothuru




                                          Quick Test Professional
                                                   Training


                          December 16th, 2009



                                                                    1
Concepts

                             •   Introduction to Automation Testing    3
                             •   VB Scripting Concepts                 11
                             •   Introduction to QTP                   19
                             •   QTP Record & Playback                 28
                             •   Actions                               34
Amarendra Kumar Kothuru




                             •   Object Repository                     43
                             •   Types of Objects                      57
                             •   Data Parameterization                 60
                             •   Synchronization                       68
                             •   Check Points & Output Values          75
                             •   Transaction Points                    86
                             •   QTP Options & Test Settings           88
                             •   Test Results                          96
                             •   Descriptive Programming               99
                             •   Regular Expressions                   106
                             •   Functions & Library Files             110
                             •   Recovery Scenarios & Error Handling   113
                             •   File System Handling                  120
                             •   Database Handling                     123
                                                                             2
Introduction to Automation Testing




                                     3
Introduction to 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…
Amarendra Kumar Kothuru




                             •   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 saves time and effort which results in reduction of the Test life cycle…




                                                                                                                       4
Automation advantages..


                           Advantages of Automated Testing

                           FAST                  Tests are run significantly faster than human users.
Amarendra Kumar Kothuru




                           Reliable              Tests perform precisely the same operations each time they are
                                                 run, thereby eliminating human error. Also reduces the chances
                                                 of missing out any scenario.
                           Repeatable            You can test how the Web site or application reacts after
                                                 repeated execution of the same operations.

                           Programmable          You can program sophisticated tests that bring out hidden
                                                 information
                           Comprehensive         You can build a suite of tests that covers every feature in your
                                                 Web site or application.
                           Reusable              You can reuse tests on different versions of a Web site or
                                                 application, even if the user interface changes.

                                                                                                                    5
Why we need Automation Testing?
Amarendra Kumar Kothuru




                          No Testing   Manual Testing      Automated Testing
                                                             Speed
                                         Time consuming
                                                             Repeatability
                                         Low reliability
                                                             Programming capabilities
                                         Human resources
                                                             Coverage
                                         Inconsistent
                                                             Reliability
                                                             Reusability




                                                                                        6
When Automation is applicable?




                            •   Regression Testing Cycles are long and iterative

                            •   If the application is planned to have multiple releases /
Amarendra Kumar Kothuru




                                builds

                            •   If it’s a long running application where in small
                                enhancements/ Bug Fixes keeps happening

                            •   Test Repeatability is required




                                                                                            7
Which Test Cases to Automate?


                                Tests that need to be run for every build of the application (sanity
                                level)
                                Tests that use multiple data values for the same actions (data driven
Amarendra Kumar Kothuru




                                tests)
                                Tests that require detailed information from application internals (e.g.,
                                SQL, GUI attributes)




                                           More repetitive execution?
                                           Better candidate for automation.




                                                                                                            8
Which Test Cases Not to Automate?


                               Usability testing
                                – "How easy is the application to use?"
                               One-time testing, "ASAP" testing
Amarendra Kumar Kothuru




                                – "We need to test NOW!"
                               Ad hoc/random testing
                                – based on intuition and knowledge of application
                               Tests without predictable results




                                              Improvisation required?
                                              Poor candidate for automation.


                                                                                    9
From Manual to Automated Testing




                                                                                                           Repeat steps until all
                               Perform user        Wait for processes to        Verify AUT functions
                                                                                                           applications are
                               actions             complete
Amarendra Kumar Kothuru




                                                                                as expected
                                                                                                           verified compliant

                                               1                            2                          3                              4




                           1                       2                            3                          4
                                                       Synchronize script
                            Generate                   playback to                                             Run test or suite of
                                                                                    Add verification
                            automated script           application                                             tests
                                                       performance



                                                                                                                                          10
VB Scripting Concepts




                        11
VB Scripting Overview


                           Variables/Objects – Dim, Set, Const, Option Explicit, Option Implicit
                           •   If -Then – ElseIf - Else – End If Conditional Statements
                           •   Select Case
Amarendra Kumar Kothuru




                           •   Control Structures
                                •   For – Next
                                •   For Each – Next
                                •   While – Wend
                                •   Do While/Until – Loop
                                •   Do - Loop – While/Until Condition
                           •   Sub Routines and Functions
                           •   Arrays
                           •   VB Script Methods – StrComp, Len, Mid, Date, Now, Instr, Msgbox, Trim, Join, Split,
                               CreateObject etc…


                                                                                                                     12
VB Scripting Concepts


                           • Dim – used to declare a variable and the variable is treated as a variant. At run-time,
                             based on the value type, memory will be allocated to the variable based on the data
                             type of value user assign to it. It is not mandatory to declare variable in VB Script.
                           • Set – It is mandatory to use this while assigning any type of object to a variable.
Amarendra Kumar Kothuru




                             E.g. Set obj = CreateObject(“ADODB.Connection”)
                           • Option Explicit – used to make the variable declaration is mandatory. If not
                             declared, user will get error message.
                           • Option Implicit – By default VB Script uses this keyword in the back ground and it
                             is not mandatory.
                           • Const – used to declare constants
                             E.g. Const var_Const = “Sony”




                                                                                                                       13
VB Scripting Concepts

                          •   If Then Conditional Statements                            •   Select Case Statement
                          • Simple If Then                • If Then – ElseIf – Else     • Select Case
                            If <Condition> Then             If <Condition 1> Then         Select Case expression
                                Statement 1                                               [Case expression-1
                                                               Statement 1
Amarendra Kumar Kothuru




                                Statement 2 etc…                                              [statements-1]]
                                                            ElseIf <Condition 2> Then
                            End If                                                        [Case expression-2
                                                               Statement 2
                                                                                              [statements-2]]
                                                            Else                          …
                                                               Statement 3                [Case expression-n
                                                            End If                            [statements-n]] ...
                          •    Nested If                                                  [Case Else
                              If <Condition1> Then
                                  Statement1              • If Then - Else                    [else statements]]
                              Else                                                        End Select
                                                            If <Condition> Then
                                  If <Condition 2> Then
                                      Statement 2               Statement 1
                                  Else                      Else
                                     Statement 3
                                                                Statement 2
                                  End If
                              End If                        End IF


                                                                                                                    14
VB Scripting Concepts

                          •   Control Structures
                          • For … Next Statement                            • Do…While/Until… Loop Statement
                            For counter = start To end [Step stepcounter]     Do [{While | Until} condition]
                                [statements]                                     [statements]
                                [Exit For]                                       [Exit Do]
Amarendra Kumar Kothuru




                                [statements]                                     [statements]
                            Next                                              Loop


                          • For Each...Next Statement                       • Do…Loop... While/Until… Statement
                            For Each element In group                         Do
                                [statements]                                         [statements]
                                [Exit For]                                       [Exit Do]
                                [statements]                                     [statements]
                            Next                                              Loop [{While | Until} condition]

                          • While. . .Wend Statement
                            While condition
                               Version [statements]
                            Wend
                                                                                                                  15
VB Scripting Concepts

                          •   Sub Routines & functions
                          • A procedure/function is a grouping of code statements that can be called by an associated
                            name to accomplish a specific task or purpose in a program. Once a procedure/function is
                            defined, it can be called from different locations in the program as needed.
                          • Difference between Sub Routine and Function – Sub Routine cannot able to return any
Amarendra Kumar Kothuru




                            value from it but function can able do it.
                          • Parameter types – ByRef, ByVal. Default Parameter Type is ByRef so that you can
                            indirectly return more than one parameter value from a function.


                          Sub Routine                                        Function
                          Sub SubRoutineName([[ByRef|ByVal] Param 1, Param   Function FunctionName ([[ByRef|ByVal] Param 1,
                            2…Param n])                                        Param 2…Param n])
                            [Statement 1]                                      [Statement 1]
                            [Statement 2]                                      [Statement 2]
                            [Exit Sub]                                         [Exit Function]
                            [Statement n]…                                     [Statement n]…
                          End Sub                                              FunctionName = Value ‘ to return value
                                                                             End Function
                                                                                                                       16
VB Scripting Concepts

                          •   Array – It is a collection of similar type of data.
                          • Static length of Array
                          • Dynamic length of Array

                              E.g. for Static length array
Amarendra Kumar Kothuru




                                 Dim var_Array(10)
                                 For counter = 0 to 9
                                    var_Array(counter) = counter
                                 Next

                              E.g. for Dynamic length array
                                 Dim var_Array()
                                 var_Value = InputBox(“Enter any number greater than zero”)
                                 While counter <= var_Value
                                    Redim Preserve var_Array(counter)
                                    var_Array(counter) = counter
                                    counter = counter + 1
                                 Wend

                                                                                              17
VB Scripting Concepts
                            •   VB Script Built–in Functions
                                Abs             Array            Asc                        Atn
                                CBool           CByte            CCur                       CDate
                                CDbl            Chr              CInt                       CLng
                                Conversions     Cos              CreateObject               CSng
                                CStr            Date             DateAdd                    DateDiff
                                DatePart        DateSerial       DateValue                  Day
Amarendra Kumar Kothuru




                                Derived         Math             Escape                     Eval Exp
                                Filter          FormatCurrency   FormatDateTime             FormatNumber
                                FormatPercent   GetLocale        GetObject                  GetRef
                                Hex             Hour             InputBox                   InStr
                                InStrRev        Int, Fix         IsArray                    IsDate
                                IsEmpty         IsNull           IsNumeric                  IsObject
                                Join            LBound           LCase                      Left
                                Len             LoadPicture      Log                        LTrim; RTrim; and Trim
                                Maths           Mid              Minute                     Month
                                MonthName       MsgBox           Now                        Oct
                                Replace         RGB              Right                      Rnd
                                Round           ScriptEngine     ScriptEngineBuildVersion   ScriptEngineMajorVersion
                                Second          SetLocale        Sgn                        ScriptEngineMinorVersion
                                Sin             Space            Split                      Sqr
                                StrComp         String           StrReverse                 Tan
                                Time            Timer            TimeSerial                 TimeValue
                                TypeName        UBound           UCase                      Unescape
                                VarType         Weekday          WeekdayName                Year
                                                                                                                       18
Amarendra Kumar Kothuru




            Introduction to QTP




19
Benefits of QTP



                            Benefits
                            • Verify the functionalities of integrated and multi environment enterprise
                              solutions.
Amarendra Kumar Kothuru




                            • Minimize the time and effort required to develop a powerful test suite.
                            • Practice collaborative   testing to leverage existing Quality Assurance
                              resources.
                            • Integrate with WinRunner, LoadRunner and Test Director.




                                                                                                          20
QTP Supports
Amarendra Kumar Kothuru




                                         QTP supports




                                                        21
QTP Add-in Manager



                           • Expands QTP capabilities for specific environments
                           • Allows for context sensitive recording depending on your environment
Amarendra Kumar Kothuru




                                 web
                                 client/server
                                 terminal emulator
                           • Allows for the verification of Environment - specific objects
                           • Allows for synchronization depending on the environment




                                                                                                    22
Amarendra Kumar Kothuru



                               QTP Add-in Manager




23
QTP User Interface

                          QuickTest Window
                          •   The QuickTest window contains the following key elements:
                          •   QuickTest title bar—Displays the name of the currently open test.
                          •   Menu bar—Displays menus of QuickTest commands.
Amarendra Kumar Kothuru




                          •   File toolbar—Contains buttons to assist you in managing your test.
                          •   Test toolbar—Contains buttons to assist you in the testing process.
                          •   Debug toolbar—Contains buttons to assist you in debugging your test (not displayed by default).
                          •   Action toolbar—Contains buttons and a list of actions, enabling you to view the details of an individual
                              action or the entire test flow (available only in the Tree View, not displayed by default).
                          •   Test pane—Contains the Tree View and Expert View tabs.
                          •   Test Details pane—Contains the Active Screen.
                          •   Data Table—Assists you to parameterize your test. The Data Table contains the Global tab and a tab
                              for each action.
                          •   Debug Viewer pane—Assists you in debugging your test. The Debug Viewer pane contains the
                              Watch Expressions, Variables, and Command tabs (not displayed by default).
                          •   Status bar—Displays the status of the QuickTest application.

                                                                                                                                     24
QTP User Interface


                                                 Test Script


                                                 Library File
Amarendra Kumar Kothuru




                                               Export view (code)




                                               Data Table window

                                               Global Sheet

                                               Local Sheet(Action1)


                                               Debug Viewer


                                                                    25
QTP Testing Process

                            Quick Test testing process consists of 7 main phases


                            1.   QTP Automation Testing Process
                                 • Test Environment
                                 • Test Conditions
Amarendra Kumar Kothuru




                            2.   Creating Test Script
                                 • Recording script using Record & Play back method
                                 • Using Keyword View
                                 • Using Descriptive Programming
                            3.   Enhancing your Test Script
                                 • Adding logic and conditional statements
                                 • Parameterization
                                 • Inserting Validation statements using checkpoints/descriptive programming
                            4.   Debugging your test
                                 • Check that it operates smoothly and without interruption.
                            5.   Run Test
                                 • Check the behavior of your application
                            6.   Analyzing the test results
                            7.   Reporting defects

                                                                                                               26
Steps to prepare Automation Testing


                             • Verify that the application under test is stable and ready for testing

                             • Verify the test case and list the steps in the correct order
Amarendra Kumar Kothuru




                             • Verify the test data to be used to record the basic steps

                             • Verify the testing environment standards are adhered to

                             • Verify the QuickTest and the add-ins , if any, are installed and running
                               without errors




                                                                                                          27
Amarendra Kumar Kothuru




            Record & Play Back




28
Record & Play Back


                             Recording Types


                             • Standard Recording : Enables you to record in normal mode without
Amarendra Kumar Kothuru




                               capturing mouse events & co-ordinates


                             • Analog Recording : Enables you to record the exact mouse &
                               keyboard operations. Quick Test tracks every movement of the
                               mouse


                             • Low Level Recording : Enables you to record on any object whether
                               or not Quick Test recognizes the specific object . This mode of
                               recording is used if the exact co-ordinates of the object is important



                                                                                                        29
Record & Play Back


                           How Quick Test Recognizes Objects


                           • For each object class, QTP has a default set of properties that it always
Amarendra Kumar Kothuru




                             learns.


                                  Mandatory Properties
                                  Assistive properties
                                  Ordinal Identifiers


                           • Usually, only a few properties are needed to uniquely identify an object and
                             those vary from object to objects.



                                                                                                            30
Record & Play Back
Amarendra Kumar Kothuru




                                    Recorded Script in Keyword view which contains
                                               descriptions for the code




                                                                                     31
Record & Play Back
Amarendra Kumar Kothuru




                                        Recorded Script in Export view
                                              contains only code




                                                                         32
Record & Play Back
Amarendra Kumar Kothuru




                          •   Record and run test on any open Browser/Windows based application - tester can record on
                              any opened browser
                          •   Open the following address/Record and run only on -      tester can record on specified
                              application/application URL only
                                                                                                                     33
Amarendra Kumar Kothuru




            Actions




34
Actions


                          •   Action is nothing but a block of statements and will be executed first when user start
                              executing the test script just like a main function in C language.

                          •   Once new test script is created, one action will be automatically created in the test script
Amarendra Kumar Kothuru




                              with the default name “Action1” and will be executed by default.

                          •   Once an action is created, ObjectRepository file(.bdb), Resources file(.mtr) and Script
                              file(.mts) would be created and one sheet would be added in Default.xls file exist in the
                              test script folder.

                          •   Inserting a new Action
                                       Insert  Call to New Action




                                                                                                                             35
Actions


                          Types of Calling an Action


                          •   Call to New Action – Calling new action into the test script
                          •
Amarendra Kumar Kothuru




                              Call to Copy of Action – Calling the existing action from other test script into current test
                              script. It is not necessary that the called action should be reusable action. User can also
                              able to make changes to the called action from local test script and it will not affect the
                              actual test script.
                              E.g. RunAction "Copy of Action2", oneIteration
                          •   Call to Existing Action – Calling the existing action from other test script into current test
                              script. It is compulsory that the called action should be a reusable action. User cannot able
                              to make changes in called action from local test script so that it won’t affect the actual test
                              script.
                              E.g. RunAction "Action3 [Test2]", oneIteration
                          •   Call to WinRunner      Test/Function – Calling WinRunner Test script or function from QTP
                              Test Script.

                                                                                                                           36
Actions


                          • Reusable Actions

                           When you plan a suite of tests, you may realize that each test requires identical activities,
                           such as logging in. For example, rather than recording the login process three times in
Amarendra Kumar Kothuru




                           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 a flight
                           reservation system in one test. Once you are satisfied with the action you recorded and
                           enhanced, you can insert the existing action into other tests.




                                      Making the action as
                                        reusable action




                                                                                                                           37
Actions


                          Insert Call to an Action

                          You can call a reusable action multiple times within a test (from the local test), and you
                          can call it from other tests. When you insert a call to an external action, the action is
Amarendra Kumar Kothuru




                          inserted in read-only format. User can view the components of the action in the action
                          tree, but you cannot modify them.

                          Inserting calls to reusable actions makes it easier to maintain your tests, because when
                          an object or procedure in your application changes, it needs to be updated only one time,
                          in the original action.

                          Note: If the test calling an action uses per-action repository mode, the called action’s
                          action object repository will be read-only (as are the steps of the called action) in the test
                          calling the action. If the test you are calling from uses a shared object repository, the
                          called action will use the same shared object repository as the test calling the action.
                          Before running the test, confirm that the shared object repository contains all the objects
                          that are in the called action. Otherwise, the test may fail.



                                                                                                                           38
Actions



                          Splitting Actions

                          User can split an existing action into two sibling
Amarendra Kumar Kothuru




                          actions or into parent-child nested actions.

                          Options disable when splitting an Action is used:

                          •   when an external action is selected
                          •   when the first line of the action is selected
                          •   while recording a test
                          •   while running a test
                          •   when you are working with a read-only test




                                                                               39
Actions

                          Nesting Actions

                          Sometimes you may want to run an action within an action. This is called nesting.
                          It helps you maintain the modularity of your test and enable you to run one action or
                          another based on the results of a conditional statement.
Amarendra Kumar Kothuru




                          Actions can be viewed from top-level test flow or drilled-down into action steps




                                                                                                                  40
Exiting Actions



                          Exit Actions

                          You can add a line in your script in the Expert View to exit an action before it runs in its
Amarendra Kumar Kothuru




                          entirety. You may want to use this option to return the current value of the action to the value
                          at a specific point in the run. There are four types of exit action statements you can use:

                          • ExitAction - Exits the current action, regardless of its iteration attributes.

                          • ExitActionIteration - Exits the current iteration of the action.

                          • ExitRun - Exits the test, regardless of its iteration attributes.

                          • ExitGlobalIteration - Exits the current global iteration.




                                                                                                                             41
Action Parameters

                          •   How to pass/return parameter values to/from an
                              Action
                                   For example, declare parameters for Action2
                                   i.e. go to “Edit -> Action -> Action Properties…
                                   -> Parameters Tab”.
                                   To pass values, add parameters in Input
Amarendra Kumar Kothuru




                                   Parameters and specify its type & Default
                                   value & Description.
                                   To return values, add parameters in Output
                                   Parameters and specify its type & Description.
                               In Action1, use the below Syntax:
                               Syntax: RunAction “ActionName”,
                                   OneIteration/AllIterations, param1, param2,
                                   param3,..... Etc.

                               E.g. In Action1,
                               Dim c
                               RunAction "Action2", OneIteration, “a”, “b”, c
                               Msgbox c

                                In Action2, retrieve the parameter values using the following Syntax so that you can read values from it
                                Msgbox Parameter(“param1”)
                                • Code in Action2 -> Parameter(“param3”) = Parameter(“param1”) & Parameter(“param2”)

                                                                                                                                           42
Amarendra Kumar Kothuru




             Object Repository




43
Object Repository


                            •   On completion of this chapter, you will be able to do the following

                            •   Define the object in QuickTest Professional
Amarendra Kumar Kothuru




                            •   Describe how objects are recognized by QuickTest Professional

                            •   Describe the role of the Object Repository

                            •   Use the Object Repository to find and add objects

                            •   Change object logical names using the Keyword View




                                                                                                      44
Object Types
Amarendra Kumar Kothuru




                                                                                                      Textbox
                                                                                                      Image


                                                                                                       Link




                           •   A QTP Object is a graphic user element in an application interface. E.g. Textbox, Link
                           •   QTP by itself does not define any object information. Instead it uses the same
                               information created by the application developers
                           •   Objects are categorized into classes. E.g. Links, text fields, graphic images
                                                                                                                        45
Object Recognition
Amarendra Kumar Kothuru




                             •   In the interface given above, we will take up the following 2 Textboxes for discussion-
                                    User Name
                                    Password
                             •   The only way to distinguish between two objects of same class is by looking at their Object
                                 Properties
                             •   Specific characteristics of an object is called Object Property
                                                                                                                               46
Object Repository

                                       Test Object information is stored in the Object Repository
Amarendra Kumar Kothuru




                            The Object Repository dialog box displays a tree of all objects in the current component or
                            in the current action or entire test
                                                                                                                          47
Assigning and Modifying a Logical Name
Amarendra Kumar Kothuru




                           When you want to make the object’s logical name more descriptive to give clarity to the test
                           script, you can modify the object’s logical name in the object repository
                           •   Open the Object Repository Dialog from the Test Script
                           •   Select the object you want to rename and right click on the object
                           •   Select rename option and change the Logical Name and the changes would be reflected
                               into the test script.
                                                                                                                          48
Object Repository
Amarendra Kumar Kothuru




                            •   QTP Object Repository stores properties of the objects during recording. These objects are
                                called as test objects
                            •   which is used by QTP to identify the objects in the AUT during runtime
                            •   To open Object Repository dialog box, Navigate to Tools      Object Repository
                            •   Click on + button and get the additional properties of the object
                                                                                                                             49
Object Highlight Feature
Amarendra Kumar Kothuru




                            •   Object highlight feature is used to highlight the particular object to check whether QTP can identify
                                that object when object description is changed
                            •   The window which contains particular object should be available to QTP, to use this feature
                            •   Select any one object in object repository, then click Highlight button. Now the object in the
                                application is highlighted by showing a frame around the object temporarily and causing it to flash
                                for sometime
                                                                                                                                        50
Types of Object Repository


                            •   There are two types of object repository :
                                      Per-Action
                                      Shared
                            •   When you plan to create tests, you must consider how you want to store the objects in
Amarendra Kumar Kothuru




                                your test.

                            •   You can have a separate action repository for each action and store the objects for
                                each action in its corresponding action repository.
                            •   you can store all the objects in your test in a common (shared) object repository file
                                that can be used among multiple tests.
                            •   Per-Action Object Repository file extension is .mtr
                            •   Shared Object Repository file extension is .tsr




                                                                                                                     51
Object Repository (Pros & Cons)



                           •   If the test does not call any external actions and the test does not contain
                               any steps or any objects, you can change the repository mode or the
                               shared object repository file being used for that test.
Amarendra Kumar Kothuru




                           •   Once any objects or steps have been added to a test, the object repository
                               mode cannot be changed from per-action to shared or vice versa. If your
                               existing test uses a shared object repository file, you can change the
                               shared object repository file that the test uses.




                                                                                                              52
Adding Objects to Object Repository


                           Adding Objects to the Object Repository
                           • When you record a test, QuickTest adds each object on which you perform
                             an operation to the object repository. You can also add objects to the object
                             repository while editing your test.
Amarendra Kumar Kothuru




                           • There are various ways to add an object to the object repository while editing
                             a test:
                                  Use the Add New Object option in the Object Repository dialog box.
                                  You can add any object as a single object or a parent object, along with
                                  all its children.
                                  Choose the View/Add Object option from the Active Screen.
                                  Insert a step in your test for a selected object from the Active Screen.




                                                                                                              53
Adding Objects to Object Repository



                          • Defining new test objects to
                            the Object Repository
Amarendra Kumar Kothuru




                           • Adding test objects to the
                             Object Repository




                                                                54
Adding Objects to Object Repository


                            •   When you record a test, QuickTest adds each object on which you perform an
                                operation to the object repository. You can also add objects to the object repository
                                while editing your test.
                            •   There are various ways to add an object to the object repository while editing a
Amarendra Kumar Kothuru




                                test:
                            •   Use the Add New Object option in the Object Repository dialog box. You can add
                                any object as a single object or a parent object, along with all its children.
                            •   Choose the View/Add Object option from the Active Screen.
                            •   Insert a step in your test for a selected object from the Active Screen.

                            Note:
                              To add objects to the object repository using the Active Screen, the Active Screen
                              must contain information for the object you want to add. You can control how
                              much information is captured in the Active Screen in the Active Screen tab of the
                              Options dialog box.



                                                                                                                        55
Object Spy




                           •   Spy on controls in browser, see their
                               properties, methods
Amarendra Kumar Kothuru




                           •   See hierarchy of browser objects




                                                                       56
Amarendra Kumar Kothuru




            Types of Objects




57
Types of Objects


                          Test Objects
                          • Each recorded browser object has its equivalent Test Object
                          • Objects Hierarchy in browser is also represented as a hierarchy in Object
                            Repository
Amarendra Kumar Kothuru




                          • New Test Objects can be added to Object Repository by right-clicking the
                            object in the Active Screen


                          Utility Objects
                          These are QuickTest environment-specific reserved objects
                           SystemUtil object
                           Desktop object
                           DataTable object
                           QCUtil object
                           Reporter object
                           Services object etc…

                                                                                                        58
Step Generator
Amarendra Kumar Kothuru




                           Replaces the Method Wizard with a dialog box that helps you quickly and easily add methods,
                           reserved objects, and function statements to your test.
                                                                                                                         59
Amarendra Kumar Kothuru




                          Data Parameterization




                                                  60
Parameterization / Data Driven Tests


                          You can use QuickTest to enhance your tests by parameterizing values in the test.
                          A parameter is a variable that is assigned a value from outside the test in which it is defined.
                          When you create a parameter in the Keyword View, QuickTest creates a corresponding line in
                          VBScript in the Expert View.
Amarendra Kumar Kothuru




                          QuickTest calls the values of a parameterized object from the Data Table using the following
                          syntax:
                          Object_Hierarchy.Method DataTable (parameterID, sheetID)

                          Object_Hierarchy - object-oriented definition of the test object.
                          Method - name of the method that QuickTest executes on the parameterized object.
                          DataTable - Data Table object.
                          parameterID - Name of the column in the Data Table
                          sheetID - Name of the sheet
                          (If the parameter is a global parameter, “dtGlobalSheet” is displayed and for Local Parameter,
                          “dtLocalSheet” is displayed.

                          Note: Recorded Test / Script is Modified in such a way that Data is driven from the excel sheet



                                                                                                                             61
Parameterization – Object Hierarchy



                           For example, suppose you are creating a test on the Mercury Tours site, and you select
                           “Paris” as your destination.
                           The following statement is inserted into your test in the Expert View:
Amarendra Kumar Kothuru




                           Browser("Mercury Tours").Page("Find Flights").WebList("depart").Select "Paris"

                           Now suppose you want to parameterize the destination, and you create a “Departure” column
                           in the Data Table. The previous statement is modified to the following:
                           Browser("Mercury Tours").Page("Find Flights").WebList("depart").Select
                                DataTable("Departure",dtGlobalSheet) and the Object Hierarchy is as follows

                           Object Hierarchy:
                           Select - is the Method Name
                           DataTable - is the Object
                           Departure - is the name of the column in the Data Table
                           dtGlobalSheet - Indicates name of the sheet in the Data Table




                                                                                                                   62
Parameterization – Parameter Types



                           Tests can be parameterize using Data Table parameters or by having QuickTest insert
                           values for you based on the parameter type and the parameter-specific preferences
                           you set.
Amarendra Kumar Kothuru




                           The following parameter types are available:

                           • Data Table Parameters
                           • Environment Variable Parameters
                           • Random Number Parameters




                                                                                                                 63
Parameterization – Data Table Parameters


                           •   User can supply the list of possible values for a parameter by creating a Data Table parameter.
                           •   Data Table parameters enable you to create a data-driven test (or action) that runs several times
                               using the data you supply.
                           •   In each repetition, or iteration, QuickTest substitutes the constant value with a different value
                               from the Data Table.
Amarendra Kumar Kothuru




                           •   By default Two sheets (Global & Action1) are available for Data Table Parameterization. Global
                               sheet is available for all Actions where as Local sheet (action1) is available only to the
                               appropriate action in the test script.


                            Data Table Methods
                               AddSheet Method
                               DeleteSheet Method
                               Export Method
                               GetCurrentRow Method
                               GetRowCount Method
                               GetSheet Method
                               GetSheetCount Method
                               Import Method
                               SetCurrentRow Method
                               SetNextRow Method
                               SetPrevRow Method

                                                                                                                                   64
Parameterization – Environment Variables



                           QuickTest can insert a value from the Environment variable list, which is a list of
                           variables and corresponding values that can be accessed from your test. Throughout
                           the test run, the value of an environment variable remains the same, regardless of the
Amarendra Kumar Kothuru




                           number of iterations.


                           Tip: The environment parameter is especially useful for localization testing, when you
                           want to test an application where the user interface strings change, depending on the
                           selected language. The environment parameter can be used for testing the same
                           application on different browsers.
                           You can also vary the input values for each language by selecting a different Data Table
                           file each time you run the test.




                                                                                                                      65
Parameterization – Environment Variables


                          There are three types of environment variables:

                          •   User-Defined Internal—variables that you define within the test. They are saved with the
                              test and accessible only within the test in which they were defined.
Amarendra Kumar Kothuru




                          •   User-Defined External—variables that you pre-defined in the active external environment
                              variables file (.xml). You can create as many files as you want and select an appropriate
                              file for each test. Note that external environment variable values are designated as read-
                              only within the test.
                              E.g. User defined Environment variable
                              Environment(“test”) = “Fujitsu”
                              Msgbox Environment(“test”) ‘display message box with the text Fujitsu

                          •   Built-in—built-in variables, such as Test path and Operating system. They are accessible
                              from all tests, and are designated as read-only.
                              E.g. Built-in Environment variable
                              var_Username = Environment(“username”) ‘returns windows login user name



                                                                                                                           66
Parameterization – Random Numbers



                           QuickTest can generate random numbers and insert them as the values for a
                           parameter. By default, the random number ranges between 0 and 100. The minimum
                           allowable value for a random number is 0 and the maximum allowable value is
Amarendra Kumar Kothuru




                           2147483647. A different random number is generated each time the parameter is
                           called.

                           E.g.
                           Browser("Mercury Tours").Page("Find Flights").WebList(“No of Seats").Select
                           RandomNumber(1, 10)

                           Note: The number of action and global iterations performed during the test run is
                           based on the number of rows in the Data Table.




                                                                                                               67
Amarendra Kumar Kothuru




               Synchronization




68
Synchronization



                           What is Synchronization

                           •   Synchronization is an enhancement to a test, to instruct QTP to wait for a
Amarendra Kumar Kothuru




                               state of a property on a particular object to change, before advancing to the
                               next step in the test

                           •   Synchronization point allows the test to pause while the AUT processes,
                               before moving on to the next step

                           •   Just as a manual tester waits for a visual cue to know whether the AUT
                               completed its processing, we need to instruct QTP to wait for a cue while
                               processing and then continue with the steps



                                                                                                               69
Synchronization

                          Where Synchronization should be added


                          •   Some objects may take several seconds longer than other objects due to processing time,
                              for example:
Amarendra Kumar Kothuru




                                   For a progress bar to reach 100%
                                   For a status message to appear
                                   For a button to become enabled
                                   For a window or pop-up message to open


                          •   On the other hand, Quick Test runs each step in the same length of time


                          •   An “Object not enabled” message appears if Quick Test runs a step and progresses to the
                              next while the previous step is not yet complete



                                                                                                                  70
Synchronization
Amarendra Kumar Kothuru




                           • To add a synchronization point, do the following-
                                Select Menu    Insert   Step   Synchronization Point
                           • Add the synchronization point immediately after the step to be synchronized

                                                                                                           71
Synchronization
Amarendra Kumar Kothuru




                             E.g. Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").
                             WebEdit("userName").WaitProperty "disabled", False, 10000
                                                                                                      72
Synchronization point settings
Amarendra Kumar Kothuru




                                                                                               Sync Step
                                                                         Global Timeout         Timeout



                           When the synchronization timeout is set for a step, this value is added to the
                           global timeout value.
                           Global Timeout + Sync Step Timeout = Total Maximum Timeout


                                                                                                            73
Synchronization


                              Synchronization Methods

                          •    WaitProperty – method is used to instruct QTP to wait the execution process until it
                               matches with the object property value based on the specified time.
Amarendra Kumar Kothuru




                               E.g. Browser("Welcome: Mercury Tours").WaitProperty "name", "Welcome: Mercury Tours", 5000




                                                      Property Name         Property value                         Time

                           •   Wait – method is used to instruct the QTP to wait the execution process based on the
                               specified time only but not on any condition.
                               E.g. Wait 5 (or) Wait(5) ‘5 Seconds

                           •   Exist – method is used to instruct QTP to wait the execution process based on the
                               specified time and returns Boolean value as per the object existence.
                               E.g. var_Exist = Browser(“Welcome: Mercury Tours”).Exist(5) ‘5 seconds



                                                                                                                            74
Amarendra Kumar Kothuru




                          Check Points and Output Values




                                                           75
Checkpoints


                          Checkpoints are the validation statements which verifies the Actual results against
                          Expected results and stores the results

                          Insert Check Points in to your test
                          Various check points used in QTP(while
Amarendra Kumar Kothuru




                          recording) are




                                                                                                                76
Checkpoints

                           Standard Check Point
                           Standard Checkpoint enables you to check an object’s property.
                           Insert->check point->standard check point
                           A pointing hand will appear and using that you can select a location in the application where standard
Amarendra Kumar Kothuru




                           check point can be inserted. If more than 1 object is associated with the selected location then ‘select an
                           Object’ dialog box appears.                                            On selecting the corresponding
                           objects and clicking ‘OK’ will display different dialog box
                                                                                      Check properties dialog box


                                                                                      Page object Check Point Properties

                                                                                      Table object Check Point Properties

                                                                                     WebEdit object Check Point Properties




                           E.g. Browser(“Google").Page(“Google”).WebEdit(“q”).Check CheckPoint("DbTable")

                                                                                                                                    77
Checkpoints
Amarendra Kumar Kothuru




                          In the Checkpoint Properties (WebEdit)             Page Checkpoint checks the characteristics of a
                          dialog box, you can specify which properties of    Web page like links, image and loading time of a
                          the object to check and edit the values of these   page. Click ‘Ok’ to add ‘Page check point to test
                          properties.                                        tree.
                                                                                                                                 78
Checkpoints


                          Database Checkpoint
                          By inserting Database checkpoints to your test scripts, you can check the contents of databases
                          accessed by your Web site or application.
                          Choose Insert ->Checkpoint ->Database checkpoint and the Database Query Wizard opens.
Amarendra Kumar Kothuru




                                                                       Click finish to go to Data base check point dialog box
                                                                                                                                79
Checkpoints
Amarendra Kumar Kothuru




                                                                      You can check that a specified value is displayed
                                                                      in a cell in a table on your Web page or in your
                                                                      application by adding a table checkpoint to your
                                                                      test.
                                                                      Click ‘Ok’ to add table check point to the test tree.




                           E.g. DbTable("DbTable").Check CheckPoint("DbTable")

                                                                                                                              80
Checkpoints
Amarendra Kumar Kothuru




                                                                                    Expected data




                                                                                 Insert statement option

                            QTP captures the current information about the database using the query you have defined and
                            saves this information as expected data. When you run the test, the database checkpoint
                            compares the current state of the database to the expected data.
                                                                                                                           81
Output Values


                            Inserting Output values (while recording)
                            Quick Test enables you to retrieve a value from your test and store it in the Data Table as
                            an output value. This output value can be subsequently used as an input variable in your
                            test.
Amarendra Kumar Kothuru




                                                                                                                      82
Output Values

                           Standard Output Value
                           When you run the test, Quick Test retrieves the current value of the property and enters it in the run-
                           time Data Table as an output value.
                           Choose Insert ->output values ->standard output values. A pointing hand appears. Click an object
                           in your Web page or application to add output values. If the location you clicked is associated with
Amarendra Kumar Kothuru




                           more than one object then ‘Select an object’ dialog box appears and on selecting an objects and
                           clicking ‘OK’ will display corresponding dialog box




                                                                                    Output value dialog box

                                                                                    Page output value Properties


                                                                                    Table output value Properties

                                                                                    WebEdit output value Properties




                                                                                                                                     83
Output Values
Amarendra Kumar Kothuru




                          In the Output Value Properties dialog                   In the Page Output Value Properties dialog box,
                          box, you can choose which property of the               you can choose which property of the page to
                          object to specify as an output value.                   specify as an output value.
                             E.g. Browser(“Google").Page(“Google”).WebEdit(“q”).Output CheckPoint("DbTable")
                                                                                                                                    84
Output Values

                          Text output value
                          Text output value from a text string retrieves the current value of the text string and enters it in the
                          run-time Data Table as an output value while running the test.
                          Choose Insert > Output Value > Text Output Value after highlighting the test string that you want to
                          specify as an output value. Click the highlighted test string with pointer hand. The Text Output Value
Amarendra Kumar Kothuru




                          Properties dialog box opens.




                                                                         Click ‘Ok’ to add Output value test to test tree.




                                                                                                                                     85
Amarendra Kumar Kothuru




            Transactions




86
Transactions

                           • A transaction represents the business process that you are interested in measuring.
                           • You can measure how long it takes to run a section of your test by defining transactions.
                           • User can Plan the Scenario as transaction and use the Start Transaction and End Transaction
                             while Recording.
Amarendra Kumar Kothuru




                           • Insert Start Transaction…


                             Services.StartTransaction "LoginTransaction"




                           • Insert End Transaction…


                             Services.EndTransaction "LoginTransaction"

                                                                                                                           87
Amarendra Kumar Kothuru




            QTP Options




88
QTP Options
Amarendra Kumar Kothuru




                             Select the check boxes “Display Add-In Manager on startup” & “Display Welcome Screen on
                             startup” in Tools  Options    General to view the Add-In Manager and Welcome screens on
                             start up
                                                                                                                   89
QTP - Options
Amarendra Kumar Kothuru




                            •   To get the execution arrow appear to help with troubleshooting click “Normal” in
                                Tools    Options    Run
                            •   To view the Test Results after each test run select “View Results” option in Tools
                                Options     Run
                                                                                                                     90
Amarendra Kumar Kothuru




            Test Settings




91
Test Settings
Amarendra Kumar Kothuru




                             Click on Modify button to update the Addins to the test script. File   Settings   Properties.
                             Select or Deselect the check boxes to manage Addins.
                                                                                                                             92
Test Settings
Amarendra Kumar Kothuru




                                 • Change the iteration settings for test execution
                                 • Change the Object Synchronization timeout to recognize the object
                                 • Enable/disable Smart Identification on Objects
                                 • Apply settings for recovery scenario at the time of script execution
                                 • File Settings Run
                                                                                                          93
Test Settings
Amarendra Kumar Kothuru




                              • Associate the library files with the test script for reusability
                              • Associate the External Data Tables with the Test script for parameterization
                              • File Settings Resources
                                                                                                               94
Test Settings
Amarendra Kumar Kothuru




                                 • Access Built-in Environment variables
                                 • Access Internal or External User defined Environment variables
                                 • File Settings Environment Variables
                                                                                                    95
Amarendra Kumar Kothuru




            Test Results




96
Test Results

                          •   After running a test, we can view a report of major events that occurred during the test run.
                          •   The Test Results window contains a description of the steps performed during the test run.
                          •   If the test contains Data Table parameters, and the test settings it shows on Test Results
                              window.
Amarendra Kumar Kothuru




                          •   Results are grouped by the actions in the test.
                          Reporter object: Using this object methods and properties, tester can send, filter and
                          analyze the results to/from Test Results window.
                             Reporter.ReportEvent – used to send result to test result window
                             Reporter.Filter – used to view the only the required results like pass/fail/etc…
                             Reporter.ReportPath – used to retrieve the folder path in which the current test's results
                             are stored. Note: but can’t able to set file path at runtime.
                          E.g:
                          1)    Reporter.ReportEvent micPass, “test case 123 is passed”, “test case for Login”
                          2)    Reporter.Filter = rfEnableErrorsOnly
                          3)    Msgbox Reporter.ReportPath

                                                                                                                          97
Test Results
Amarendra Kumar Kothuru




                                         Test Results Summary




                                          Individual result – Pass Result




                                          Individual result – Fail Result

                                                                            98
Amarendra Kumar Kothuru




                          Descriptive Programming




                                                    99
Descriptive Programming



                            Record and Playback Limitations

                            •   Objects will not be identified if the objects in the application are
Amarendra Kumar Kothuru




                                dynamic in nature.
                            •   QTP performance may decrease when the object repository becomes
                                to large, due to the no. of objects added. As the object repository
                                increases, more resources are required to recognize the objects which
                                may decrease performance.
                            •   To create scripts using Record and replay application must be up
                                running. Which means will have to wait till application deployed to start
                                creating QTP scripts.
                            •   Scripts maintenance is not easy if UI changes.




                                                                                                            100
Descriptive Programming


                          Descriptive Programming: Instead of storing physical descriptions in Object
                          Repository we will pass physical descriptions of the objects during script run-
                          time to identify and access the objects
Amarendra Kumar Kothuru




                          Advantages:
                               • One can start creating scripts without application is actually deployed.
                               • The objects in the application are dynamic in nature and need special
                                 handling to identify the object.
                               • Object Identification performance would be much faster than OR based
                                 identification.
                               • Scripts re-usable.
                               • Scripts maintenance would be much easier if UI changes.
                               • User does not wish to use shared repository.


                                                                                                        101
Descriptive Programming

                          1. By entering programmatic descriptions directly into statements:
                          Creating Dynamic Test Object:
                                   micClass(“property1:=value1”[,“property2:=value2”, etc…])
                          Where:
                               micClass is the object class as assigned by QuickTest and,
Amarendra Kumar Kothuru




                               property:=value is a description of the object separated by commas

                           •   At least one Property is required to recognize the object by QTP at runtime.
                           •   If two or more objects contain similar property values, then use “Index” property to recognize the object
                               uniquely. Index property value starts from 0(Zero)
                           •   Use regular expressions to recognize objects if object property values tentative.

                           E.g. 1) Browser(“name:=Google”).Page(“title:=Google”).WebEdit(“name:=q”).Set “Tester”
                                2) Browser(“name:=Google”).Page(“title:=Google”).WebButton(“name:=Google Search”).Click
                                3) Browser(“name:=Google”).Page(“title:=Google”).WebButton(“name:=Google.*”).Click

                           •   Tester learns object’s properties to recognize the objects using the Object Spy or object repository.
                           •   Tester writes code to describe object’s properties in the script.
                           •   At run-time, QuickTest bypasses the Object Repository and creates a test object from the script.
                           •   Programmatic description is useful if you want to perform an operation on an object that is not stored in the
                               Object Repository.

                                                                                                                                           102
Descriptive Programming

                             2. By using description objects for Programmatic description:
                             Defining Description objects,


                             For Browser:
Amarendra Kumar Kothuru




                               Set desc_BrowserProperty = Description.Create()
                               desc_BrowserProperty("name").Value = “Google"
                             For Page:
                               Set desc_PageProperty = Description.Create()
                                desc_PageProperty("title").Value = “Google“


                             Creating Dynamic Test Object
                             Assigning Description object to Test Object
                             E.g.   1) Set BrowserObj = Browser(desc_BrowserProperty)
                                    2) Set BrowserPageObj = Browser(desc_BrowserProperty).Page(desc_PageProperty)


                             Access Dynamic test objects
                             E.g.   1) BrowserPageObj.WebEdit(“name:=q”).Set “tester”
                                     2) BrowserObj.Close
                                                                                                                    103
Descriptive Programming


                           Web Objects standard properties
                           WebEdit – name                                 WebList – name
                           Link – name                                    Image – name, alt, file name
Amarendra Kumar Kothuru




                           WebRadioButton – name                          WebCheckBox – name
                           WebElement – innertext, innerhtml              WebTable – name, html id
                           Browser – name                                 Page – title
                           WebButton - name



                           SAP Objects standard properties
                           For all SAP Objects, either id property or combination of name & GuiComponentType
                           properties is required.




                                                                                                               104
Descriptive Programming


                          Validations using Descriptive Programming

                          GetROProperty: method is used to retrieve specified test object property value at runtime.
Amarendra Kumar Kothuru




                          E.g.

                          1) var_Value = Browser(“name:=Google”).Page(“title:=Google”).WebEdit(“name:=q”).GetROProperty(“value”)

                          If Strcomp(var_Value,”tester”,0) = 0 Then

                                 Reporter.ReportEvent micPass, “User entered correct value as “ & var_Value, “Passed”

                          Else

                                 Reporter.ReportEvent micFail, “User entered wrong value as “ & var_Value, “Failed”

                          End If



                          2) var_Status =
                          Browser(“name:=Google”).Page(“title:=Google”).WebEdit(“name:=q”).GetROProperty(“disabled”)


                                                                                                                           105
Amarendra Kumar Kothuru




             Regular Expressions




106
Regular Expressions

                          •   A regular expression is a formula for matching strings that follow some pattern.
                          •   A regular expression (abbreviated as regexp or regex, with plural forms regexps, regexes, or
                              regexen) is a string that describes or matches a set of strings, according to certain syntax rules.
                          •   You can use a regular expression to identify specific text in a document and either remove it
                              completely or replace it with other text.
                          •   In QuickTest Regular Expressions can be used in 3 places:
Amarendra Kumar Kothuru




                                  Object Repository
                                  CheckPoints
                                  RegExp object
                          •   regex is the most basic pattern, simply matching the literal text regex. A "match" is the piece of text,
                              or sequence of bytes or characters that pattern was found to correspond to by the regex processing.
                          •   The regular expression serves as a template for matching a character pattern to the string being
                              searched. The regular expression pattern (expression) is stored in the Pattern property of the
                              RegExp object.

                               Order Precedence
                               Operator                       Description
                                                             Escape
                               (), (?:), (?=), []             Parentheses and Brackets
                               *, +, ?, {n}, {n,}, {n,m}      Quantifiers
                               ^, $, anymetacharacter        Anchors and Sequences
                               |                              Alternation

                                                                                                                                     107
Regular Expressions


                           •   [  ^ $ . | ? * + ( ) special characters are Meta Characters. If you want to use any of these
                               characters as a literal in a regex, you need to escape them with a backslash. If you want to
                               match 1+1=2, the correct regex is 1+1=2. Otherwise, the plus sign will have a special
                               meaning.
                           •   To match an a or an e, use [ae]. You could use this in gr[ae]y to match either gray or grey.
Amarendra Kumar Kothuru




                           •   [0-9a-fA-F] matches a single character, case insensitively.
                           •   d matches a single character that is a digit, w matches a "word character“ (alphanumeric
                               characters plus underscore), and s matches a whitespace character (includes tabs and line
                               breaks).
                           •   Non Printable characters - Use t to match a tab character, r for carriage return and n for line
                               feed.
                           •   The dot matches a single character, except line break characters. gr.y matches gray, grey,
                               gr%y, etc.
                           •   The question mark makes the preceding token in the regular expression optional.
                           •   E.g.: colou?r matches colour or color
                           •   Use curly braces to specify a specific amount of repetition. Use [1-9][0-9]{3} to match a number
                               between 1000 and 9999. [1-9][0-9]{2,4} matches a number between 100 and 99999.
                           •   07[-./]04[-./]76 matches 07/04/76, 07-04-76, or 07.04.76
                           •   .* matches any string
                           •   (1[012]|[1-9]):[0-5][0-9] (am|pm) matches mm:ss am/pm time format
                           •   d{5} matches any five digit number
                                                                                                                             108
Regular Expressions


                          RegExp object: It provides support for regular expression matching; for the ability to search
                          strings for substrings matching general or specific patterns.

                          Properties: Global, IgnoreCase, Pattern, MultiLine
Amarendra Kumar Kothuru




                          Methods: Execute, Test, Replace

                          Instantiate and access the regular expression object, with the following code:

                          E.g. 1)
                          Dim oRegEx 'Create variable.
                          Set oRegEx = New RegExp 'Create regular expression.
                          oRegEx.Pattern = "[0-9a-zA-Z_-()]" 'Set pattern.
                          oRegEx.IgnoreCase = bIgnoreCase 'Set case insensitivity.
                          oRegEx.Global = True 'Set global applicability and match all occurrences in the search string
                          Set desc_Broswer = Description.Create()
                          desc_Broswer("name").Value = Pattern 'applies the pattern to the description object
                          Set BrowserObj = Browser(desc_Broswer)
                          BrowserObj.Navigate "www.yahoo.com"


                                                                                                                     109
Amarendra Kumar Kothuru




                          Functions & Library Files




                                                      110
Function Definition Generator


                          Creating Functions/Sub
                          Insert  Function Definition Generator …

                          •   Using this generator, user can able to create a
                              function definition without knowing the syntax
Amarendra Kumar Kothuru




                          •   When tester register the user defined function on
                              any test object event and make it as default, then
                              at runtime, QTP executes the user defined
                              function when that event is fired irrespective of
                              built-in functionality of the event.
                          •   RegisterUserFunc method is used to register
                              the function
                          •    Tester should prepare the logic himself/herself to
                              implement functionality




                                Syntax: RegisterUserFunc test Object class name, Event name, Boolean value
                                Boolean value: True – used to set as Default False – used to set as Built-in only
                                                                                                                    111
Library Files


                            •   Function Library is nothing but a file which may contain user defined elements like
                                Variables, Functions, Sub Routines, Classes, Objects etc…
                            •   It is generally used for reusability
Amarendra Kumar Kothuru




                            •   Can able associate with multiple test scripts
                            •   Provides global scope to the user defined elements
                            •   Library file extension in QTP can be either .Vbs (Visual basic scripting file) or .Qfl or
                                .Txt (Text file)
                            •   Reduces the script preparation time
                            •   Script Maintenance is easier




                                                                                                                        112
Amarendra Kumar Kothuru




                          Recovery Scenarios & Error Handling




                                                                113
Recovery Scenarios

                              •   To 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
                                        Trigger Event
                                        Recovery Operation
Amarendra Kumar Kothuru




                                        Post Recovery Run Option
                          1                                            2




                                                                                                                                  114
Recovery Scenarios

                           3
                                               4
Amarendra Kumar Kothuru




                           5                   6




                                                   115
Quick Test Professional Training Document
Quick Test Professional Training Document
Quick Test Professional Training Document
Quick Test Professional Training Document
Quick Test Professional Training Document
Quick Test Professional Training Document
Quick Test Professional Training Document
Quick Test Professional Training Document
Quick Test Professional Training Document
Quick Test Professional Training Document
Quick Test Professional Training Document
Quick Test Professional Training Document

Contenu connexe

Similaire à Quick Test Professional Training Document

Презентация
ПрезентацияПрезентация
Презентацияguest22d71d
 
20110812 CyberTAN presentation
20110812 CyberTAN presentation20110812 CyberTAN presentation
20110812 CyberTAN presentationRichard Hsu
 
How to make Automation an asset for Organization
How to make Automation an asset for OrganizationHow to make Automation an asset for Organization
How to make Automation an asset for Organizationanuvip
 
Qtp training session I
Qtp training session IQtp training session I
Qtp training session IAisha Mazhar
 
Centralized test automation framework implementation
Centralized test automation framework implementationCentralized test automation framework implementation
Centralized test automation framework implementationBharathi Krishnamurthi
 
Web Application Release
Web Application ReleaseWeb Application Release
Web Application ReleasePiyush Mattoo
 
Automated testing handbook from Linda Hayes
Automated testing handbook from Linda HayesAutomated testing handbook from Linda Hayes
Automated testing handbook from Linda HayesCristiano Caetano
 
How to bake in quality in agile scrum projects
How to bake in quality in agile scrum projectsHow to bake in quality in agile scrum projects
How to bake in quality in agile scrum projectsSantanu Bhattacharya
 
When is software test automation worth it?
When is software test automation worth it?When is software test automation worth it?
When is software test automation worth it?Claudia Baur
 
Test automation lesson
Test automation lessonTest automation lesson
Test automation lessonSadaaki Emura
 
Automated testing
Automated testingAutomated testing
Automated testings0194975
 
Automation Tools Overview
Automation Tools OverviewAutomation Tools Overview
Automation Tools OverviewMurageppa-QA
 
Automation Tool Overview
Automation Tool OverviewAutomation Tool Overview
Automation Tool OverviewANKUR-BA
 
Automation Tools Overview
Automation Tools OverviewAutomation Tools Overview
Automation Tools OverviewSachin-QA
 
Software Test Automation
Software Test AutomationSoftware Test Automation
Software Test AutomationJosh Case
 
Presentation1
Presentation1Presentation1
Presentation1anuvip
 

Similaire à Quick Test Professional Training Document (20)

Chapter 10
Chapter 10Chapter 10
Chapter 10
 
Презентация
ПрезентацияПрезентация
Презентация
 
20110812 CyberTAN presentation
20110812 CyberTAN presentation20110812 CyberTAN presentation
20110812 CyberTAN presentation
 
How to make Automation an asset for Organization
How to make Automation an asset for OrganizationHow to make Automation an asset for Organization
How to make Automation an asset for Organization
 
Qtp training session I
Qtp training session IQtp training session I
Qtp training session I
 
Centralized test automation framework implementation
Centralized test automation framework implementationCentralized test automation framework implementation
Centralized test automation framework implementation
 
Web Application Release
Web Application ReleaseWeb Application Release
Web Application Release
 
Loadrunner Online Training
Loadrunner Online TrainingLoadrunner Online Training
Loadrunner Online Training
 
Automated testing handbook from Linda Hayes
Automated testing handbook from Linda HayesAutomated testing handbook from Linda Hayes
Automated testing handbook from Linda Hayes
 
How to bake in quality in agile scrum projects
How to bake in quality in agile scrum projectsHow to bake in quality in agile scrum projects
How to bake in quality in agile scrum projects
 
When is software test automation worth it?
When is software test automation worth it?When is software test automation worth it?
When is software test automation worth it?
 
Test automation lesson
Test automation lessonTest automation lesson
Test automation lesson
 
Automated testing
Automated testingAutomated testing
Automated testing
 
Automation Tools Overview
Automation Tools OverviewAutomation Tools Overview
Automation Tools Overview
 
Automation Tool Overview
Automation Tool OverviewAutomation Tool Overview
Automation Tool Overview
 
Automation Tools Overview
Automation Tools OverviewAutomation Tools Overview
Automation Tools Overview
 
Software Test Automation
Software Test AutomationSoftware Test Automation
Software Test Automation
 
Presentation1
Presentation1Presentation1
Presentation1
 
Application Testing Suite
Application Testing SuiteApplication Testing Suite
Application Testing Suite
 
Vaidyanathan Ramalingam Trade Off Economics In Testing Conference Speech
Vaidyanathan Ramalingam Trade Off Economics In Testing Conference SpeechVaidyanathan Ramalingam Trade Off Economics In Testing Conference Speech
Vaidyanathan Ramalingam Trade Off Economics In Testing Conference Speech
 

Dernier

Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 

Dernier (20)

Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 

Quick Test Professional Training Document

  • 1. Amarendra Kumar Kothuru Quick Test Professional Training December 16th, 2009 1
  • 2. Concepts • Introduction to Automation Testing 3 • VB Scripting Concepts 11 • Introduction to QTP 19 • QTP Record & Playback 28 • Actions 34 Amarendra Kumar Kothuru • Object Repository 43 • Types of Objects 57 • Data Parameterization 60 • Synchronization 68 • Check Points & Output Values 75 • Transaction Points 86 • QTP Options & Test Settings 88 • Test Results 96 • Descriptive Programming 99 • Regular Expressions 106 • Functions & Library Files 110 • Recovery Scenarios & Error Handling 113 • File System Handling 120 • Database Handling 123 2
  • 4. Introduction to 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… Amarendra Kumar Kothuru • 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 saves time and effort which results in reduction of the Test life cycle… 4
  • 5. Automation advantages.. Advantages of Automated Testing FAST Tests are run significantly faster than human users. Amarendra Kumar Kothuru Reliable Tests perform precisely the same operations each time they are run, thereby eliminating human error. Also reduces the chances of missing out any scenario. Repeatable You can test how the Web site or application reacts after repeated execution of the same operations. Programmable You can program sophisticated tests that bring out hidden information Comprehensive You can build a suite of tests that covers every feature in your Web site or application. Reusable You can reuse tests on different versions of a Web site or application, even if the user interface changes. 5
  • 6. Why we need Automation Testing? Amarendra Kumar Kothuru No Testing Manual Testing Automated Testing Speed Time consuming Repeatability Low reliability Programming capabilities Human resources Coverage Inconsistent Reliability Reusability 6
  • 7. When Automation is applicable? • Regression Testing Cycles are long and iterative • If the application is planned to have multiple releases / Amarendra Kumar Kothuru builds • If it’s a long running application where in small enhancements/ Bug Fixes keeps happening • Test Repeatability is required 7
  • 8. Which Test Cases to Automate? Tests that need to be run for every build of the application (sanity level) Tests that use multiple data values for the same actions (data driven Amarendra Kumar Kothuru tests) Tests that require detailed information from application internals (e.g., SQL, GUI attributes) More repetitive execution? Better candidate for automation. 8
  • 9. Which Test Cases Not to Automate? Usability testing – "How easy is the application to use?" One-time testing, "ASAP" testing Amarendra Kumar Kothuru – "We need to test NOW!" Ad hoc/random testing – based on intuition and knowledge of application Tests without predictable results Improvisation required? Poor candidate for automation. 9
  • 10. From Manual to Automated Testing Repeat steps until all Perform user Wait for processes to Verify AUT functions applications are actions complete Amarendra Kumar Kothuru as expected verified compliant 1 2 3 4 1 2 3 4 Synchronize script Generate playback to Run test or suite of Add verification automated script application tests performance 10
  • 12. VB Scripting Overview Variables/Objects – Dim, Set, Const, Option Explicit, Option Implicit • If -Then – ElseIf - Else – End If Conditional Statements • Select Case Amarendra Kumar Kothuru • Control Structures • For – Next • For Each – Next • While – Wend • Do While/Until – Loop • Do - Loop – While/Until Condition • Sub Routines and Functions • Arrays • VB Script Methods – StrComp, Len, Mid, Date, Now, Instr, Msgbox, Trim, Join, Split, CreateObject etc… 12
  • 13. VB Scripting Concepts • Dim – used to declare a variable and the variable is treated as a variant. At run-time, based on the value type, memory will be allocated to the variable based on the data type of value user assign to it. It is not mandatory to declare variable in VB Script. • Set – It is mandatory to use this while assigning any type of object to a variable. Amarendra Kumar Kothuru E.g. Set obj = CreateObject(“ADODB.Connection”) • Option Explicit – used to make the variable declaration is mandatory. If not declared, user will get error message. • Option Implicit – By default VB Script uses this keyword in the back ground and it is not mandatory. • Const – used to declare constants E.g. Const var_Const = “Sony” 13
  • 14. VB Scripting Concepts • If Then Conditional Statements • Select Case Statement • Simple If Then • If Then – ElseIf – Else • Select Case If <Condition> Then If <Condition 1> Then Select Case expression Statement 1 [Case expression-1 Statement 1 Amarendra Kumar Kothuru Statement 2 etc… [statements-1]] ElseIf <Condition 2> Then End If [Case expression-2 Statement 2 [statements-2]] Else … Statement 3 [Case expression-n End If [statements-n]] ... • Nested If [Case Else If <Condition1> Then Statement1 • If Then - Else [else statements]] Else End Select If <Condition> Then If <Condition 2> Then Statement 2 Statement 1 Else Else Statement 3 Statement 2 End If End If End IF 14
  • 15. VB Scripting Concepts • Control Structures • For … Next Statement • Do…While/Until… Loop Statement For counter = start To end [Step stepcounter] Do [{While | Until} condition] [statements] [statements] [Exit For] [Exit Do] Amarendra Kumar Kothuru [statements] [statements] Next Loop • For Each...Next Statement • Do…Loop... While/Until… Statement For Each element In group Do [statements] [statements] [Exit For] [Exit Do] [statements] [statements] Next Loop [{While | Until} condition] • While. . .Wend Statement While condition Version [statements] Wend 15
  • 16. VB Scripting Concepts • Sub Routines & functions • A procedure/function is a grouping of code statements that can be called by an associated name to accomplish a specific task or purpose in a program. Once a procedure/function is defined, it can be called from different locations in the program as needed. • Difference between Sub Routine and Function – Sub Routine cannot able to return any Amarendra Kumar Kothuru value from it but function can able do it. • Parameter types – ByRef, ByVal. Default Parameter Type is ByRef so that you can indirectly return more than one parameter value from a function. Sub Routine Function Sub SubRoutineName([[ByRef|ByVal] Param 1, Param Function FunctionName ([[ByRef|ByVal] Param 1, 2…Param n]) Param 2…Param n]) [Statement 1] [Statement 1] [Statement 2] [Statement 2] [Exit Sub] [Exit Function] [Statement n]… [Statement n]… End Sub FunctionName = Value ‘ to return value End Function 16
  • 17. VB Scripting Concepts • Array – It is a collection of similar type of data. • Static length of Array • Dynamic length of Array E.g. for Static length array Amarendra Kumar Kothuru Dim var_Array(10) For counter = 0 to 9 var_Array(counter) = counter Next E.g. for Dynamic length array Dim var_Array() var_Value = InputBox(“Enter any number greater than zero”) While counter <= var_Value Redim Preserve var_Array(counter) var_Array(counter) = counter counter = counter + 1 Wend 17
  • 18. VB Scripting Concepts • VB Script Built–in Functions Abs Array Asc Atn CBool CByte CCur CDate CDbl Chr CInt CLng Conversions Cos CreateObject CSng CStr Date DateAdd DateDiff DatePart DateSerial DateValue Day Amarendra Kumar Kothuru Derived Math Escape Eval Exp Filter FormatCurrency FormatDateTime FormatNumber FormatPercent GetLocale GetObject GetRef Hex Hour InputBox InStr InStrRev Int, Fix IsArray IsDate IsEmpty IsNull IsNumeric IsObject Join LBound LCase Left Len LoadPicture Log LTrim; RTrim; and Trim Maths Mid Minute Month MonthName MsgBox Now Oct Replace RGB Right Rnd Round ScriptEngine ScriptEngineBuildVersion ScriptEngineMajorVersion Second SetLocale Sgn ScriptEngineMinorVersion Sin Space Split Sqr StrComp String StrReverse Tan Time Timer TimeSerial TimeValue TypeName UBound UCase Unescape VarType Weekday WeekdayName Year 18
  • 19. Amarendra Kumar Kothuru Introduction to QTP 19
  • 20. Benefits of QTP Benefits • Verify the functionalities of integrated and multi environment enterprise solutions. Amarendra Kumar Kothuru • Minimize the time and effort required to develop a powerful test suite. • Practice collaborative testing to leverage existing Quality Assurance resources. • Integrate with WinRunner, LoadRunner and Test Director. 20
  • 21. QTP Supports Amarendra Kumar Kothuru QTP supports 21
  • 22. QTP Add-in Manager • Expands QTP capabilities for specific environments • Allows for context sensitive recording depending on your environment Amarendra Kumar Kothuru web client/server terminal emulator • Allows for the verification of Environment - specific objects • Allows for synchronization depending on the environment 22
  • 23. Amarendra Kumar Kothuru QTP Add-in Manager 23
  • 24. QTP User Interface QuickTest Window • The QuickTest window contains the following key elements: • QuickTest title bar—Displays the name of the currently open test. • Menu bar—Displays menus of QuickTest commands. Amarendra Kumar Kothuru • File toolbar—Contains buttons to assist you in managing your test. • Test toolbar—Contains buttons to assist you in the testing process. • Debug toolbar—Contains buttons to assist you in debugging your test (not displayed by default). • Action toolbar—Contains buttons and a list of actions, enabling you to view the details of an individual action or the entire test flow (available only in the Tree View, not displayed by default). • Test pane—Contains the Tree View and Expert View tabs. • Test Details pane—Contains the Active Screen. • Data Table—Assists you to parameterize your test. The Data Table contains the Global tab and a tab for each action. • Debug Viewer pane—Assists you in debugging your test. The Debug Viewer pane contains the Watch Expressions, Variables, and Command tabs (not displayed by default). • Status bar—Displays the status of the QuickTest application. 24
  • 25. QTP User Interface Test Script Library File Amarendra Kumar Kothuru Export view (code) Data Table window Global Sheet Local Sheet(Action1) Debug Viewer 25
  • 26. QTP Testing Process Quick Test testing process consists of 7 main phases 1. QTP Automation Testing Process • Test Environment • Test Conditions Amarendra Kumar Kothuru 2. Creating Test Script • Recording script using Record & Play back method • Using Keyword View • Using Descriptive Programming 3. Enhancing your Test Script • Adding logic and conditional statements • Parameterization • Inserting Validation statements using checkpoints/descriptive programming 4. Debugging your test • Check that it operates smoothly and without interruption. 5. Run Test • Check the behavior of your application 6. Analyzing the test results 7. Reporting defects 26
  • 27. Steps to prepare Automation Testing • Verify that the application under test is stable and ready for testing • Verify the test case and list the steps in the correct order Amarendra Kumar Kothuru • Verify the test data to be used to record the basic steps • Verify the testing environment standards are adhered to • Verify the QuickTest and the add-ins , if any, are installed and running without errors 27
  • 28. Amarendra Kumar Kothuru Record & Play Back 28
  • 29. Record & Play Back Recording Types • Standard Recording : Enables you to record in normal mode without Amarendra Kumar Kothuru capturing mouse events & co-ordinates • Analog Recording : Enables you to record the exact mouse & keyboard operations. Quick Test tracks every movement of the mouse • Low Level Recording : Enables you to record on any object whether or not Quick Test recognizes the specific object . This mode of recording is used if the exact co-ordinates of the object is important 29
  • 30. Record & Play Back How Quick Test Recognizes Objects • For each object class, QTP has a default set of properties that it always Amarendra Kumar Kothuru learns. Mandatory Properties Assistive properties Ordinal Identifiers • Usually, only a few properties are needed to uniquely identify an object and those vary from object to objects. 30
  • 31. Record & Play Back Amarendra Kumar Kothuru Recorded Script in Keyword view which contains descriptions for the code 31
  • 32. Record & Play Back Amarendra Kumar Kothuru Recorded Script in Export view contains only code 32
  • 33. Record & Play Back Amarendra Kumar Kothuru • Record and run test on any open Browser/Windows based application - tester can record on any opened browser • Open the following address/Record and run only on - tester can record on specified application/application URL only 33
  • 35. Actions • Action is nothing but a block of statements and will be executed first when user start executing the test script just like a main function in C language. • Once new test script is created, one action will be automatically created in the test script Amarendra Kumar Kothuru with the default name “Action1” and will be executed by default. • Once an action is created, ObjectRepository file(.bdb), Resources file(.mtr) and Script file(.mts) would be created and one sheet would be added in Default.xls file exist in the test script folder. • Inserting a new Action Insert Call to New Action 35
  • 36. Actions Types of Calling an Action • Call to New Action – Calling new action into the test script • Amarendra Kumar Kothuru Call to Copy of Action – Calling the existing action from other test script into current test script. It is not necessary that the called action should be reusable action. User can also able to make changes to the called action from local test script and it will not affect the actual test script. E.g. RunAction "Copy of Action2", oneIteration • Call to Existing Action – Calling the existing action from other test script into current test script. It is compulsory that the called action should be a reusable action. User cannot able to make changes in called action from local test script so that it won’t affect the actual test script. E.g. RunAction "Action3 [Test2]", oneIteration • Call to WinRunner Test/Function – Calling WinRunner Test script or function from QTP Test Script. 36
  • 37. Actions • Reusable Actions When you plan a suite of tests, you may realize that each test requires identical activities, such as logging in. For example, rather than recording the login process three times in Amarendra Kumar Kothuru 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 a flight reservation system in one test. Once you are satisfied with the action you recorded and enhanced, you can insert the existing action into other tests. Making the action as reusable action 37
  • 38. Actions Insert Call to an Action You can call a reusable action multiple times within a test (from the local test), and you can call it from other tests. When you insert a call to an external action, the action is Amarendra Kumar Kothuru inserted in read-only format. User can view the components of the action in the action tree, but you cannot modify them. Inserting calls to reusable actions makes it easier to maintain your tests, because when an object or procedure in your application changes, it needs to be updated only one time, in the original action. Note: If the test calling an action uses per-action repository mode, the called action’s action object repository will be read-only (as are the steps of the called action) in the test calling the action. If the test you are calling from uses a shared object repository, the called action will use the same shared object repository as the test calling the action. Before running the test, confirm that the shared object repository contains all the objects that are in the called action. Otherwise, the test may fail. 38
  • 39. Actions Splitting Actions User can split an existing action into two sibling Amarendra Kumar Kothuru actions or into parent-child nested actions. Options disable when splitting an Action is used: • when an external action is selected • when the first line of the action is selected • while recording a test • while running a test • when you are working with a read-only test 39
  • 40. Actions Nesting Actions Sometimes you may want to run an action within an action. This is called nesting. It helps you maintain the modularity of your test and enable you to run one action or another based on the results of a conditional statement. Amarendra Kumar Kothuru Actions can be viewed from top-level test flow or drilled-down into action steps 40
  • 41. Exiting Actions Exit Actions You can add a line in your script in the Expert View to exit an action before it runs in its Amarendra Kumar Kothuru entirety. You may want to use this option to return the current value of the action to the value at a specific point in the run. There are four types of exit action statements you can use: • ExitAction - Exits the current action, regardless of its iteration attributes. • ExitActionIteration - Exits the current iteration of the action. • ExitRun - Exits the test, regardless of its iteration attributes. • ExitGlobalIteration - Exits the current global iteration. 41
  • 42. Action Parameters • How to pass/return parameter values to/from an Action For example, declare parameters for Action2 i.e. go to “Edit -> Action -> Action Properties… -> Parameters Tab”. To pass values, add parameters in Input Amarendra Kumar Kothuru Parameters and specify its type & Default value & Description. To return values, add parameters in Output Parameters and specify its type & Description. In Action1, use the below Syntax: Syntax: RunAction “ActionName”, OneIteration/AllIterations, param1, param2, param3,..... Etc. E.g. In Action1, Dim c RunAction "Action2", OneIteration, “a”, “b”, c Msgbox c In Action2, retrieve the parameter values using the following Syntax so that you can read values from it Msgbox Parameter(“param1”) • Code in Action2 -> Parameter(“param3”) = Parameter(“param1”) & Parameter(“param2”) 42
  • 43. Amarendra Kumar Kothuru Object Repository 43
  • 44. Object Repository • On completion of this chapter, you will be able to do the following • Define the object in QuickTest Professional Amarendra Kumar Kothuru • Describe how objects are recognized by QuickTest Professional • Describe the role of the Object Repository • Use the Object Repository to find and add objects • Change object logical names using the Keyword View 44
  • 45. Object Types Amarendra Kumar Kothuru Textbox Image Link • A QTP Object is a graphic user element in an application interface. E.g. Textbox, Link • QTP by itself does not define any object information. Instead it uses the same information created by the application developers • Objects are categorized into classes. E.g. Links, text fields, graphic images 45
  • 46. Object Recognition Amarendra Kumar Kothuru • In the interface given above, we will take up the following 2 Textboxes for discussion- User Name Password • The only way to distinguish between two objects of same class is by looking at their Object Properties • Specific characteristics of an object is called Object Property 46
  • 47. Object Repository Test Object information is stored in the Object Repository Amarendra Kumar Kothuru The Object Repository dialog box displays a tree of all objects in the current component or in the current action or entire test 47
  • 48. Assigning and Modifying a Logical Name Amarendra Kumar Kothuru When you want to make the object’s logical name more descriptive to give clarity to the test script, you can modify the object’s logical name in the object repository • Open the Object Repository Dialog from the Test Script • Select the object you want to rename and right click on the object • Select rename option and change the Logical Name and the changes would be reflected into the test script. 48
  • 49. Object Repository Amarendra Kumar Kothuru • QTP Object Repository stores properties of the objects during recording. These objects are called as test objects • which is used by QTP to identify the objects in the AUT during runtime • To open Object Repository dialog box, Navigate to Tools Object Repository • Click on + button and get the additional properties of the object 49
  • 50. Object Highlight Feature Amarendra Kumar Kothuru • Object highlight feature is used to highlight the particular object to check whether QTP can identify that object when object description is changed • The window which contains particular object should be available to QTP, to use this feature • Select any one object in object repository, then click Highlight button. Now the object in the application is highlighted by showing a frame around the object temporarily and causing it to flash for sometime 50
  • 51. Types of Object Repository • There are two types of object repository : Per-Action Shared • When you plan to create tests, you must consider how you want to store the objects in Amarendra Kumar Kothuru your test. • You can have a separate action repository for each action and store the objects for each action in its corresponding action repository. • you can store all the objects in your test in a common (shared) object repository file that can be used among multiple tests. • Per-Action Object Repository file extension is .mtr • Shared Object Repository file extension is .tsr 51
  • 52. Object Repository (Pros & Cons) • If the test does not call any external actions and the test does not contain any steps or any objects, you can change the repository mode or the shared object repository file being used for that test. Amarendra Kumar Kothuru • Once any objects or steps have been added to a test, the object repository mode cannot be changed from per-action to shared or vice versa. If your existing test uses a shared object repository file, you can change the shared object repository file that the test uses. 52
  • 53. Adding Objects to Object Repository Adding Objects to the Object Repository • When you record a test, QuickTest adds each object on which you perform an operation to the object repository. You can also add objects to the object repository while editing your test. Amarendra Kumar Kothuru • There are various ways to add an object to the object repository while editing a test: Use the Add New Object option in the Object Repository dialog box. You can add any object as a single object or a parent object, along with all its children. Choose the View/Add Object option from the Active Screen. Insert a step in your test for a selected object from the Active Screen. 53
  • 54. Adding Objects to Object Repository • Defining new test objects to the Object Repository Amarendra Kumar Kothuru • Adding test objects to the Object Repository 54
  • 55. Adding Objects to Object Repository • When you record a test, QuickTest adds each object on which you perform an operation to the object repository. You can also add objects to the object repository while editing your test. • There are various ways to add an object to the object repository while editing a Amarendra Kumar Kothuru test: • Use the Add New Object option in the Object Repository dialog box. You can add any object as a single object or a parent object, along with all its children. • Choose the View/Add Object option from the Active Screen. • Insert a step in your test for a selected object from the Active Screen. Note: To add objects to the object repository using the Active Screen, the Active Screen must contain information for the object you want to add. You can control how much information is captured in the Active Screen in the Active Screen tab of the Options dialog box. 55
  • 56. Object Spy • Spy on controls in browser, see their properties, methods Amarendra Kumar Kothuru • See hierarchy of browser objects 56
  • 57. Amarendra Kumar Kothuru Types of Objects 57
  • 58. Types of Objects Test Objects • Each recorded browser object has its equivalent Test Object • Objects Hierarchy in browser is also represented as a hierarchy in Object Repository Amarendra Kumar Kothuru • New Test Objects can be added to Object Repository by right-clicking the object in the Active Screen Utility Objects These are QuickTest environment-specific reserved objects SystemUtil object Desktop object DataTable object QCUtil object Reporter object Services object etc… 58
  • 59. Step Generator Amarendra Kumar Kothuru Replaces the Method Wizard with a dialog box that helps you quickly and easily add methods, reserved objects, and function statements to your test. 59
  • 60. Amarendra Kumar Kothuru Data Parameterization 60
  • 61. Parameterization / Data Driven Tests You can use QuickTest to enhance your tests by parameterizing values in the test. A parameter is a variable that is assigned a value from outside the test in which it is defined. When you create a parameter in the Keyword View, QuickTest creates a corresponding line in VBScript in the Expert View. Amarendra Kumar Kothuru QuickTest calls the values of a parameterized object from the Data Table using the following syntax: Object_Hierarchy.Method DataTable (parameterID, sheetID) Object_Hierarchy - object-oriented definition of the test object. Method - name of the method that QuickTest executes on the parameterized object. DataTable - Data Table object. parameterID - Name of the column in the Data Table sheetID - Name of the sheet (If the parameter is a global parameter, “dtGlobalSheet” is displayed and for Local Parameter, “dtLocalSheet” is displayed. Note: Recorded Test / Script is Modified in such a way that Data is driven from the excel sheet 61
  • 62. Parameterization – Object Hierarchy For example, suppose you are creating a test on the Mercury Tours site, and you select “Paris” as your destination. The following statement is inserted into your test in the Expert View: Amarendra Kumar Kothuru Browser("Mercury Tours").Page("Find Flights").WebList("depart").Select "Paris" Now suppose you want to parameterize the destination, and you create a “Departure” column in the Data Table. The previous statement is modified to the following: Browser("Mercury Tours").Page("Find Flights").WebList("depart").Select DataTable("Departure",dtGlobalSheet) and the Object Hierarchy is as follows Object Hierarchy: Select - is the Method Name DataTable - is the Object Departure - is the name of the column in the Data Table dtGlobalSheet - Indicates name of the sheet in the Data Table 62
  • 63. Parameterization – Parameter Types Tests can be parameterize using Data Table parameters or by having QuickTest insert values for you based on the parameter type and the parameter-specific preferences you set. Amarendra Kumar Kothuru The following parameter types are available: • Data Table Parameters • Environment Variable Parameters • Random Number Parameters 63
  • 64. Parameterization – Data Table Parameters • User can supply the list of possible values for a parameter by creating a Data Table parameter. • Data Table parameters enable you to create a data-driven test (or action) that runs several times using the data you supply. • In each repetition, or iteration, QuickTest substitutes the constant value with a different value from the Data Table. Amarendra Kumar Kothuru • By default Two sheets (Global & Action1) are available for Data Table Parameterization. Global sheet is available for all Actions where as Local sheet (action1) is available only to the appropriate action in the test script. Data Table Methods AddSheet Method DeleteSheet Method Export Method GetCurrentRow Method GetRowCount Method GetSheet Method GetSheetCount Method Import Method SetCurrentRow Method SetNextRow Method SetPrevRow Method 64
  • 65. Parameterization – Environment Variables QuickTest can insert a value from the Environment variable list, which is a list of variables and corresponding values that can be accessed from your test. Throughout the test run, the value of an environment variable remains the same, regardless of the Amarendra Kumar Kothuru number of iterations. Tip: The environment parameter is especially useful for localization testing, when you want to test an application where the user interface strings change, depending on the selected language. The environment parameter can be used for testing the same application on different browsers. You can also vary the input values for each language by selecting a different Data Table file each time you run the test. 65
  • 66. Parameterization – Environment Variables There are three types of environment variables: • User-Defined Internal—variables that you define within the test. They are saved with the test and accessible only within the test in which they were defined. Amarendra Kumar Kothuru • User-Defined External—variables that you pre-defined in the active external environment variables file (.xml). You can create as many files as you want and select an appropriate file for each test. Note that external environment variable values are designated as read- only within the test. E.g. User defined Environment variable Environment(“test”) = “Fujitsu” Msgbox Environment(“test”) ‘display message box with the text Fujitsu • Built-in—built-in variables, such as Test path and Operating system. They are accessible from all tests, and are designated as read-only. E.g. Built-in Environment variable var_Username = Environment(“username”) ‘returns windows login user name 66
  • 67. Parameterization – Random Numbers QuickTest can generate random numbers and insert them as the values for a parameter. By default, the random number ranges between 0 and 100. The minimum allowable value for a random number is 0 and the maximum allowable value is Amarendra Kumar Kothuru 2147483647. A different random number is generated each time the parameter is called. E.g. Browser("Mercury Tours").Page("Find Flights").WebList(“No of Seats").Select RandomNumber(1, 10) Note: The number of action and global iterations performed during the test run is based on the number of rows in the Data Table. 67
  • 68. Amarendra Kumar Kothuru Synchronization 68
  • 69. Synchronization What is Synchronization • Synchronization is an enhancement to a test, to instruct QTP to wait for a Amarendra Kumar Kothuru state of a property on a particular object to change, before advancing to the next step in the test • Synchronization point allows the test to pause while the AUT processes, before moving on to the next step • Just as a manual tester waits for a visual cue to know whether the AUT completed its processing, we need to instruct QTP to wait for a cue while processing and then continue with the steps 69
  • 70. Synchronization Where Synchronization should be added • Some objects may take several seconds longer than other objects due to processing time, for example: Amarendra Kumar Kothuru For a progress bar to reach 100% For a status message to appear For a button to become enabled For a window or pop-up message to open • On the other hand, Quick Test runs each step in the same length of time • An “Object not enabled” message appears if Quick Test runs a step and progresses to the next while the previous step is not yet complete 70
  • 71. Synchronization Amarendra Kumar Kothuru • To add a synchronization point, do the following- Select Menu Insert Step Synchronization Point • Add the synchronization point immediately after the step to be synchronized 71
  • 72. Synchronization Amarendra Kumar Kothuru E.g. Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours"). WebEdit("userName").WaitProperty "disabled", False, 10000 72
  • 73. Synchronization point settings Amarendra Kumar Kothuru Sync Step Global Timeout Timeout When the synchronization timeout is set for a step, this value is added to the global timeout value. Global Timeout + Sync Step Timeout = Total Maximum Timeout 73
  • 74. Synchronization Synchronization Methods • WaitProperty – method is used to instruct QTP to wait the execution process until it matches with the object property value based on the specified time. Amarendra Kumar Kothuru E.g. Browser("Welcome: Mercury Tours").WaitProperty "name", "Welcome: Mercury Tours", 5000 Property Name Property value Time • Wait – method is used to instruct the QTP to wait the execution process based on the specified time only but not on any condition. E.g. Wait 5 (or) Wait(5) ‘5 Seconds • Exist – method is used to instruct QTP to wait the execution process based on the specified time and returns Boolean value as per the object existence. E.g. var_Exist = Browser(“Welcome: Mercury Tours”).Exist(5) ‘5 seconds 74
  • 75. Amarendra Kumar Kothuru Check Points and Output Values 75
  • 76. Checkpoints Checkpoints are the validation statements which verifies the Actual results against Expected results and stores the results Insert Check Points in to your test Various check points used in QTP(while Amarendra Kumar Kothuru recording) are 76
  • 77. Checkpoints Standard Check Point Standard Checkpoint enables you to check an object’s property. Insert->check point->standard check point A pointing hand will appear and using that you can select a location in the application where standard Amarendra Kumar Kothuru check point can be inserted. If more than 1 object is associated with the selected location then ‘select an Object’ dialog box appears. On selecting the corresponding objects and clicking ‘OK’ will display different dialog box Check properties dialog box Page object Check Point Properties Table object Check Point Properties WebEdit object Check Point Properties E.g. Browser(“Google").Page(“Google”).WebEdit(“q”).Check CheckPoint("DbTable") 77
  • 78. Checkpoints Amarendra Kumar Kothuru In the Checkpoint Properties (WebEdit) Page Checkpoint checks the characteristics of a dialog box, you can specify which properties of Web page like links, image and loading time of a the object to check and edit the values of these page. Click ‘Ok’ to add ‘Page check point to test properties. tree. 78
  • 79. Checkpoints Database Checkpoint By inserting Database checkpoints to your test scripts, you can check the contents of databases accessed by your Web site or application. Choose Insert ->Checkpoint ->Database checkpoint and the Database Query Wizard opens. Amarendra Kumar Kothuru Click finish to go to Data base check point dialog box 79
  • 80. Checkpoints Amarendra Kumar Kothuru You can check that a specified value is displayed in a cell in a table on your Web page or in your application by adding a table checkpoint to your test. Click ‘Ok’ to add table check point to the test tree. E.g. DbTable("DbTable").Check CheckPoint("DbTable") 80
  • 81. Checkpoints Amarendra Kumar Kothuru Expected data Insert statement option QTP captures the current information about the database using the query you have defined and saves this information as expected data. When you run the test, the database checkpoint compares the current state of the database to the expected data. 81
  • 82. Output Values Inserting Output values (while recording) Quick Test enables you to retrieve a value from your test and store it in the Data Table as an output value. This output value can be subsequently used as an input variable in your test. Amarendra Kumar Kothuru 82
  • 83. Output Values Standard Output Value When you run the test, Quick Test retrieves the current value of the property and enters it in the run- time Data Table as an output value. Choose Insert ->output values ->standard output values. A pointing hand appears. Click an object in your Web page or application to add output values. If the location you clicked is associated with Amarendra Kumar Kothuru more than one object then ‘Select an object’ dialog box appears and on selecting an objects and clicking ‘OK’ will display corresponding dialog box Output value dialog box Page output value Properties Table output value Properties WebEdit output value Properties 83
  • 84. Output Values Amarendra Kumar Kothuru In the Output Value Properties dialog In the Page Output Value Properties dialog box, box, you can choose which property of the you can choose which property of the page to object to specify as an output value. specify as an output value. E.g. Browser(“Google").Page(“Google”).WebEdit(“q”).Output CheckPoint("DbTable") 84
  • 85. Output Values Text output value Text output value from a text string retrieves the current value of the text string and enters it in the run-time Data Table as an output value while running the test. Choose Insert > Output Value > Text Output Value after highlighting the test string that you want to specify as an output value. Click the highlighted test string with pointer hand. The Text Output Value Amarendra Kumar Kothuru Properties dialog box opens. Click ‘Ok’ to add Output value test to test tree. 85
  • 86. Amarendra Kumar Kothuru Transactions 86
  • 87. Transactions • A transaction represents the business process that you are interested in measuring. • You can measure how long it takes to run a section of your test by defining transactions. • User can Plan the Scenario as transaction and use the Start Transaction and End Transaction while Recording. Amarendra Kumar Kothuru • Insert Start Transaction… Services.StartTransaction "LoginTransaction" • Insert End Transaction… Services.EndTransaction "LoginTransaction" 87
  • 88. Amarendra Kumar Kothuru QTP Options 88
  • 89. QTP Options Amarendra Kumar Kothuru Select the check boxes “Display Add-In Manager on startup” & “Display Welcome Screen on startup” in Tools Options General to view the Add-In Manager and Welcome screens on start up 89
  • 90. QTP - Options Amarendra Kumar Kothuru • To get the execution arrow appear to help with troubleshooting click “Normal” in Tools Options Run • To view the Test Results after each test run select “View Results” option in Tools Options Run 90
  • 91. Amarendra Kumar Kothuru Test Settings 91
  • 92. Test Settings Amarendra Kumar Kothuru Click on Modify button to update the Addins to the test script. File Settings Properties. Select or Deselect the check boxes to manage Addins. 92
  • 93. Test Settings Amarendra Kumar Kothuru • Change the iteration settings for test execution • Change the Object Synchronization timeout to recognize the object • Enable/disable Smart Identification on Objects • Apply settings for recovery scenario at the time of script execution • File Settings Run 93
  • 94. Test Settings Amarendra Kumar Kothuru • Associate the library files with the test script for reusability • Associate the External Data Tables with the Test script for parameterization • File Settings Resources 94
  • 95. Test Settings Amarendra Kumar Kothuru • Access Built-in Environment variables • Access Internal or External User defined Environment variables • File Settings Environment Variables 95
  • 96. Amarendra Kumar Kothuru Test Results 96
  • 97. Test Results • After running a test, we can view a report of major events that occurred during the test run. • The Test Results window contains a description of the steps performed during the test run. • If the test contains Data Table parameters, and the test settings it shows on Test Results window. Amarendra Kumar Kothuru • Results are grouped by the actions in the test. Reporter object: Using this object methods and properties, tester can send, filter and analyze the results to/from Test Results window. Reporter.ReportEvent – used to send result to test result window Reporter.Filter – used to view the only the required results like pass/fail/etc… Reporter.ReportPath – used to retrieve the folder path in which the current test's results are stored. Note: but can’t able to set file path at runtime. E.g: 1) Reporter.ReportEvent micPass, “test case 123 is passed”, “test case for Login” 2) Reporter.Filter = rfEnableErrorsOnly 3) Msgbox Reporter.ReportPath 97
  • 98. Test Results Amarendra Kumar Kothuru Test Results Summary Individual result – Pass Result Individual result – Fail Result 98
  • 99. Amarendra Kumar Kothuru Descriptive Programming 99
  • 100. Descriptive Programming Record and Playback Limitations • Objects will not be identified if the objects in the application are Amarendra Kumar Kothuru dynamic in nature. • QTP performance may decrease when the object repository becomes to large, due to the no. of objects added. As the object repository increases, more resources are required to recognize the objects which may decrease performance. • To create scripts using Record and replay application must be up running. Which means will have to wait till application deployed to start creating QTP scripts. • Scripts maintenance is not easy if UI changes. 100
  • 101. Descriptive Programming Descriptive Programming: Instead of storing physical descriptions in Object Repository we will pass physical descriptions of the objects during script run- time to identify and access the objects Amarendra Kumar Kothuru Advantages: • One can start creating scripts without application is actually deployed. • The objects in the application are dynamic in nature and need special handling to identify the object. • Object Identification performance would be much faster than OR based identification. • Scripts re-usable. • Scripts maintenance would be much easier if UI changes. • User does not wish to use shared repository. 101
  • 102. Descriptive Programming 1. By entering programmatic descriptions directly into statements: Creating Dynamic Test Object: micClass(“property1:=value1”[,“property2:=value2”, etc…]) Where: micClass is the object class as assigned by QuickTest and, Amarendra Kumar Kothuru property:=value is a description of the object separated by commas • At least one Property is required to recognize the object by QTP at runtime. • If two or more objects contain similar property values, then use “Index” property to recognize the object uniquely. Index property value starts from 0(Zero) • Use regular expressions to recognize objects if object property values tentative. E.g. 1) Browser(“name:=Google”).Page(“title:=Google”).WebEdit(“name:=q”).Set “Tester” 2) Browser(“name:=Google”).Page(“title:=Google”).WebButton(“name:=Google Search”).Click 3) Browser(“name:=Google”).Page(“title:=Google”).WebButton(“name:=Google.*”).Click • Tester learns object’s properties to recognize the objects using the Object Spy or object repository. • Tester writes code to describe object’s properties in the script. • At run-time, QuickTest bypasses the Object Repository and creates a test object from the script. • Programmatic description is useful if you want to perform an operation on an object that is not stored in the Object Repository. 102
  • 103. Descriptive Programming 2. By using description objects for Programmatic description: Defining Description objects, For Browser: Amarendra Kumar Kothuru Set desc_BrowserProperty = Description.Create() desc_BrowserProperty("name").Value = “Google" For Page: Set desc_PageProperty = Description.Create() desc_PageProperty("title").Value = “Google“ Creating Dynamic Test Object Assigning Description object to Test Object E.g. 1) Set BrowserObj = Browser(desc_BrowserProperty) 2) Set BrowserPageObj = Browser(desc_BrowserProperty).Page(desc_PageProperty) Access Dynamic test objects E.g. 1) BrowserPageObj.WebEdit(“name:=q”).Set “tester” 2) BrowserObj.Close 103
  • 104. Descriptive Programming Web Objects standard properties WebEdit – name WebList – name Link – name Image – name, alt, file name Amarendra Kumar Kothuru WebRadioButton – name WebCheckBox – name WebElement – innertext, innerhtml WebTable – name, html id Browser – name Page – title WebButton - name SAP Objects standard properties For all SAP Objects, either id property or combination of name & GuiComponentType properties is required. 104
  • 105. Descriptive Programming Validations using Descriptive Programming GetROProperty: method is used to retrieve specified test object property value at runtime. Amarendra Kumar Kothuru E.g. 1) var_Value = Browser(“name:=Google”).Page(“title:=Google”).WebEdit(“name:=q”).GetROProperty(“value”) If Strcomp(var_Value,”tester”,0) = 0 Then Reporter.ReportEvent micPass, “User entered correct value as “ & var_Value, “Passed” Else Reporter.ReportEvent micFail, “User entered wrong value as “ & var_Value, “Failed” End If 2) var_Status = Browser(“name:=Google”).Page(“title:=Google”).WebEdit(“name:=q”).GetROProperty(“disabled”) 105
  • 106. Amarendra Kumar Kothuru Regular Expressions 106
  • 107. Regular Expressions • A regular expression is a formula for matching strings that follow some pattern. • A regular expression (abbreviated as regexp or regex, with plural forms regexps, regexes, or regexen) is a string that describes or matches a set of strings, according to certain syntax rules. • You can use a regular expression to identify specific text in a document and either remove it completely or replace it with other text. • In QuickTest Regular Expressions can be used in 3 places: Amarendra Kumar Kothuru Object Repository CheckPoints RegExp object • regex is the most basic pattern, simply matching the literal text regex. A "match" is the piece of text, or sequence of bytes or characters that pattern was found to correspond to by the regex processing. • The regular expression serves as a template for matching a character pattern to the string being searched. The regular expression pattern (expression) is stored in the Pattern property of the RegExp object. Order Precedence Operator Description Escape (), (?:), (?=), [] Parentheses and Brackets *, +, ?, {n}, {n,}, {n,m} Quantifiers ^, $, anymetacharacter Anchors and Sequences | Alternation 107
  • 108. Regular Expressions • [ ^ $ . | ? * + ( ) special characters are Meta Characters. If you want to use any of these characters as a literal in a regex, you need to escape them with a backslash. If you want to match 1+1=2, the correct regex is 1+1=2. Otherwise, the plus sign will have a special meaning. • To match an a or an e, use [ae]. You could use this in gr[ae]y to match either gray or grey. Amarendra Kumar Kothuru • [0-9a-fA-F] matches a single character, case insensitively. • d matches a single character that is a digit, w matches a "word character“ (alphanumeric characters plus underscore), and s matches a whitespace character (includes tabs and line breaks). • Non Printable characters - Use t to match a tab character, r for carriage return and n for line feed. • The dot matches a single character, except line break characters. gr.y matches gray, grey, gr%y, etc. • The question mark makes the preceding token in the regular expression optional. • E.g.: colou?r matches colour or color • Use curly braces to specify a specific amount of repetition. Use [1-9][0-9]{3} to match a number between 1000 and 9999. [1-9][0-9]{2,4} matches a number between 100 and 99999. • 07[-./]04[-./]76 matches 07/04/76, 07-04-76, or 07.04.76 • .* matches any string • (1[012]|[1-9]):[0-5][0-9] (am|pm) matches mm:ss am/pm time format • d{5} matches any five digit number 108
  • 109. Regular Expressions RegExp object: It provides support for regular expression matching; for the ability to search strings for substrings matching general or specific patterns. Properties: Global, IgnoreCase, Pattern, MultiLine Amarendra Kumar Kothuru Methods: Execute, Test, Replace Instantiate and access the regular expression object, with the following code: E.g. 1) Dim oRegEx 'Create variable. Set oRegEx = New RegExp 'Create regular expression. oRegEx.Pattern = "[0-9a-zA-Z_-()]" 'Set pattern. oRegEx.IgnoreCase = bIgnoreCase 'Set case insensitivity. oRegEx.Global = True 'Set global applicability and match all occurrences in the search string Set desc_Broswer = Description.Create() desc_Broswer("name").Value = Pattern 'applies the pattern to the description object Set BrowserObj = Browser(desc_Broswer) BrowserObj.Navigate "www.yahoo.com" 109
  • 110. Amarendra Kumar Kothuru Functions & Library Files 110
  • 111. Function Definition Generator Creating Functions/Sub Insert Function Definition Generator … • Using this generator, user can able to create a function definition without knowing the syntax Amarendra Kumar Kothuru • When tester register the user defined function on any test object event and make it as default, then at runtime, QTP executes the user defined function when that event is fired irrespective of built-in functionality of the event. • RegisterUserFunc method is used to register the function • Tester should prepare the logic himself/herself to implement functionality Syntax: RegisterUserFunc test Object class name, Event name, Boolean value Boolean value: True – used to set as Default False – used to set as Built-in only 111
  • 112. Library Files • Function Library is nothing but a file which may contain user defined elements like Variables, Functions, Sub Routines, Classes, Objects etc… • It is generally used for reusability Amarendra Kumar Kothuru • Can able associate with multiple test scripts • Provides global scope to the user defined elements • Library file extension in QTP can be either .Vbs (Visual basic scripting file) or .Qfl or .Txt (Text file) • Reduces the script preparation time • Script Maintenance is easier 112
  • 113. Amarendra Kumar Kothuru Recovery Scenarios & Error Handling 113
  • 114. Recovery Scenarios • To 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 Trigger Event Recovery Operation Amarendra Kumar Kothuru Post Recovery Run Option 1 2 114
  • 115. Recovery Scenarios 3 4 Amarendra Kumar Kothuru 5 6 115