Thomson reuters qtp training presentation

4,510 views

Published on

QTP Training

Published in: Education, Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,510
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
499
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Thomson reuters qtp training presentation

  1. 1. Amarendra Kumar Kothuru Quick Test Professional Training December 16th, 2009 1
  2. 2. Concepts • Introduction to Automation Testing 3 • VB Scripting Concepts 11 • Introduction to QTP 19 • QTP Record & Playback 28 • Actions 34Amarendra 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
  3. 3. Introduction to Automation Testing 3
  4. 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. 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. 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. 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. 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 drivenAmarendra 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. 9. Which Test Cases Not to Automate? Usability testing – "How easy is the application to use?" One-time testing, "ASAP" testingAmarendra 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. 10. From Manual to Automated Testing Repeat steps until all Perform user Wait for processes to Verify AUT functions applications are actions completeAmarendra 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
  11. 11. VB Scripting Concepts 11
  12. 12. VB Scripting Overview Variables/Objects – Dim, Set, Const, Option Explicit, Option Implicit • If -Then – ElseIf - Else – End If Conditional Statements • Select CaseAmarendra 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. 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. 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 1Amarendra 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. 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. 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 anyAmarendra 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. 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 arrayAmarendra 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. 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 DayAmarendra 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. 19. Amarendra Kumar Kothuru Introduction to QTP19
  20. 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. 21. QTP SupportsAmarendra Kumar Kothuru QTP supports 21
  22. 22. QTP Add-in Manager • Expands QTP capabilities for specific environments • Allows for context sensitive recording depending on your environmentAmarendra Kumar Kothuru web client/server terminal emulator • Allows for the verification of Environment - specific objects • Allows for synchronization depending on the environment 22
  23. 23. Amarendra Kumar Kothuru QTP Add-in Manager23
  24. 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. 25. QTP User Interface Test Script Library FileAmarendra Kumar Kothuru Export view (code) Data Table window Global Sheet Local Sheet(Action1) Debug Viewer 25
  26. 26. QTP Testing Process Quick Test testing process consists of 7 main phases 1. QTP Automation Testing Process • Test Environment • Test ConditionsAmarendra 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. 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 orderAmarendra 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. 28. Amarendra Kumar Kothuru Record & Play Back28
  29. 29. Record & Play Back Recording Types • Standard Recording : Enables you to record in normal mode withoutAmarendra 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. 30. Record & Play Back How Quick Test Recognizes Objects • For each object class, QTP has a default set of properties that it alwaysAmarendra 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. 31. Record & Play BackAmarendra Kumar Kothuru Recorded Script in Keyword view which contains descriptions for the code 31
  32. 32. Record & Play BackAmarendra Kumar Kothuru Recorded Script in Export view contains only code 32
  33. 33. Record & Play BackAmarendra 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
  34. 34. Amarendra Kumar Kothuru Actions34
  35. 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 scriptAmarendra 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. 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. 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 inAmarendra 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. 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 isAmarendra 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. 39. Actions Splitting Actions User can split an existing action into two siblingAmarendra 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. 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. 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 itsAmarendra 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. 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 InputAmarendra 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. 43. Amarendra Kumar Kothuru Object Repository43
  44. 44. Object Repository • On completion of this chapter, you will be able to do the following • Define the object in QuickTest ProfessionalAmarendra 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. 45. Object TypesAmarendra 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. 46. Object RecognitionAmarendra 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. 47. Object Repository Test Object information is stored in the Object RepositoryAmarendra 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. 48. Assigning and Modifying a Logical NameAmarendra 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. 49. Object RepositoryAmarendra 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. 50. Object Highlight FeatureAmarendra 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. 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 inAmarendra 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. 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. 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. 54. Adding Objects to Object Repository • Defining new test objects to the Object RepositoryAmarendra Kumar Kothuru • Adding test objects to the Object Repository 54
  55. 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 aAmarendra 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. 56. Object Spy • Spy on controls in browser, see their properties, methodsAmarendra Kumar Kothuru • See hierarchy of browser objects 56
  57. 57. Amarendra Kumar Kothuru Types of Objects57
  58. 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 RepositoryAmarendra 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. 59. Step GeneratorAmarendra 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. 60. Amarendra Kumar Kothuru Data Parameterization 60
  61. 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. 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. 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. 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. 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 theAmarendra 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. 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. 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 isAmarendra 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. 68. Amarendra Kumar Kothuru Synchronization68
  69. 69. Synchronization What is Synchronization • Synchronization is an enhancement to a test, to instruct QTP to wait for aAmarendra 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. 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. 71. SynchronizationAmarendra 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. 72. SynchronizationAmarendra Kumar Kothuru E.g. Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours"). WebEdit("userName").WaitProperty "disabled", False, 10000 72
  73. 73. Synchronization point settingsAmarendra 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. 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. 75. Amarendra Kumar Kothuru Check Points and Output Values 75
  76. 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(whileAmarendra Kumar Kothuru recording) are 76
  77. 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 standardAmarendra 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. 78. CheckpointsAmarendra 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. 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. 80. CheckpointsAmarendra 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. 81. CheckpointsAmarendra 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. 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. 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 withAmarendra 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. 84. Output ValuesAmarendra 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. 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 ValueAmarendra Kumar Kothuru Properties dialog box opens. Click ‘Ok’ to add Output value test to test tree. 85
  86. 86. Amarendra Kumar Kothuru Transactions86
  87. 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. 88. Amarendra Kumar Kothuru QTP Options88
  89. 89. QTP OptionsAmarendra 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. 90. QTP - OptionsAmarendra 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. 91. Amarendra Kumar Kothuru Test Settings91
  92. 92. Test SettingsAmarendra 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. 93. Test SettingsAmarendra 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. 94. Test SettingsAmarendra 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. 95. Test SettingsAmarendra Kumar Kothuru • Access Built-in Environment variables • Access Internal or External User defined Environment variables • File Settings Environment Variables 95
  96. 96. Amarendra Kumar Kothuru Test Results96
  97. 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 tests 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. 98. Test ResultsAmarendra Kumar Kothuru Test Results Summary Individual result – Pass Result Individual result – Fail Result 98
  99. 99. Amarendra Kumar Kothuru Descriptive Programming 99
  100. 100. Descriptive Programming Record and Playback Limitations • Objects will not be identified if the objects in the application areAmarendra 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. 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 objectsAmarendra 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. 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. 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. 104. Descriptive Programming Web Objects standard properties WebEdit – name WebList – name Link – name Image – name, alt, file nameAmarendra 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. 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. 106. Amarendra Kumar Kothuru Regular Expressions106
  107. 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. 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. 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, MultiLineAmarendra 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. 110. Amarendra Kumar Kothuru Functions & Library Files 110
  111. 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 syntaxAmarendra 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

×