WinRunner Training

  • 34,630 views
Uploaded on

Win Runner Training - Good One

Win Runner Training - Good One

More in: Business , Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
34,630
On Slideshare
0
From Embeds
0
Number of Embeds
5

Actions

Shares
Downloads
0
Comments
33
Likes
20

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Winrunner Training Objective of the Course
    • Understand the benefits of automated testing
    • To get an insight into the working of automated test tools
    • To use and understand the features of Winrunner
    • Creation of test scripts using Winrunner
  • 2. Benefits of Automated Testing WinRunner Testing Process WinRunner Recording Mode Working with other Test Suite Tools
  • 3. Manual Vs. Automated Testing
    • Manual Testing:
    • Is time-consuming and tedious
    • Requires a heavy investment in human resources
    • Time constraints often make it impossible to manually test every feature thoroughly before the software is released
    • Automated Testing:
    • Dramatically speed up the testing process
    • Creation of test scripts which check all aspects of the application
    • Execute these tests on each new build
  • 4. Benefits of Automated Testing Fast: Run tests significantly faster than human users Reliable: Tests perform precisely the same operations each time they are run, thereby eliminating human error Repeatable: You can test how the software reacts under repeated execution of the same operations Programmable: You can program sophisticated tests that bring out hidden information from the application Comprehensive: You can build a suite of tests that covers every feature in your application Reusable: You can reuse tests on different versions of an application, even if the user interface changes
  • 5. WinRunner Testing Process
    • 1 Create the GUI Map
      • WinRunner must learn to recognize the objects in an application in order to run tests
      • The preferred way to teach WinRunner your objects depends on the GUI map mode
    • 2 Create Tests
      • WinRunner writes scripts automatically when recording actions in applications
      • One can program directly in Mercury Interactive’s Test Script Language (TSL)
    • 3 Debug Tests
      • You debug the tests to check that they operate smoothly and without interruption
  • 6. WinRunner Testing Process
    • 4 Run Tests
      • Run tests in Verify mode to test your application
      • It compares the current data of the application being tested to the expected data captured earlier
      • If any mismatches are found, WinRunner captures them as actual results
    • 5 View Results
      • After each test run, WinRunner displays the results in a report
      • The report details all the major events that occurred during the run, such as checkpoints, error messages, system messages, or user messages
    • 6 Report Defects
      • If a test run fails due to a defect in the application being tested it can be reported directly from the Test Results window
      • This information is sent via e-mail to the quality assurance manager, who tracks the defect until it is fixed
  • 7. Recording Mode
    • Context Sensitivity
    • Context Sensitivity records operations in terms of GUI objects.
    • For e.g.
    • if you record a mouse click on OK button. WinRunner generates following TSL statements-
    • Analog Mode
    • Analog Mode Records the exact coordinates traveled by the mouse
    • For e.g.
    • if you record a mouse click on OK button. WinRunner generates following TSL statements
    button_press (“ OK ”); move_locator_track (1); mtype (&quot;<T110><kLeft>-&quot;); mtype (&quot;<kLeft>+&quot;);
  • 8. Choosing a Recording Mode
    • Choose Context Sensitive if...
    • The application contains GUI objects
    • Exact mouse movements are not required
    • You plan to reuse the test in different versions of the application
    • Choose Analog if...
    • The application contains bitmap areas (such as a drawing area)
    • Exact mouse movements are required
  • 9.
    • Starting WinRunner
      • To start WinRunner, click Start > Programs > WinRunner > WinRunner
    Recording User Actions
  • 10.
    • Creating a New test
      • Click on New Test
    Recording User Actions
  • 11. WinRunner Main Window
  • 12. WinRunner Standard Toolbar
  • 13. Recording a Test
    • To Record a Test in WinRunner, Select the Record Button from the Standard Toolbar
  • 14. Recording a Test
    • Open the Application and Enter the Data
    Automatic Script Generation Enter Application Data
  • 15. Benefits of Automated Testing WinRunner Testing Process WinRunner Recording Mode Working with other Test Suite Tools
  • 16. Working with Other Test Suite Tools WinRunner works with other Test Suite tools to provide an integrated solution for all phases of the testing process I.e. Test Planning, Test Development, GUI and Load Testing, Defect Tracking
    • Test Director : Software Test Management Tool
      • Creation of a database of manual and automated tests, building of test cycles, running tests, and report and track defects
      • With WinRunner, tests can be directly saved into the Test Director database
      • Tests can be executed in WinRunner and the overall results can be reviewed in Test Director
    • Load Runner : Testing tool for Client/Server Applications
      • Using Load Runner, you can emulate an environment in which many users (virtual users) are simultaneously engaged in a single server application
      • You can test an application’s performance “under load” by simultaneously activating virtual users on multiple host computers.
  • 17. Summary
    • Advantages of Automated Testing over Manual Testing (Fast, Reliable, Repeatable, Programmable, Comprehensive, Reusable)
    • The WinRunner Testing Process
      • Creating the GUI Map,Creating Tests,Debugging Tests,Running Tests,Viewing Results, Reporting Defects
    • WinRunner Recording Modes (Context Sensitivity,Analog)
    • Recording a Test
    • Working with other Test Suite Tools (Test Director, Load Runner)
  • 18. LAB EXERCISE
  • 19.
    • Record Login Process from Flight Reservation Sample Application in Context Sensitivity Mode
    • Record Flight Reservation Sample Application for Insert Order,Open Order and Fax Order
    • Record Burger Application for Order Entry Box
  • 20. Day 2
    • Topic
    • Setting up GUI Map
    • Managing GUI Map
    • Using the Rapid Test Script Wizard
  • 21. How Does WinRunner Create the Script?
  • 22. How Does WinRunner Create the Script? John set_window(&quot;Login&quot;, 10); edit_set (&quot;Name&quot;, ”John&quot;); Recording WinRunner AUT
    • WinRunner adds windows and objects to the GUI Map as they are encountered by the user during recording
    • The GUI Map contains information that allows WinRunner TSL statements to be translated into Windows commands, and vice versa
    GUI Map
  • 23. How Does WinRunner Run the Script? set_window(&quot;Login&quot;, 10); edit_set (&quot;Name&quot;, ”John&quot;); John Playback WinRunner AUT
    • When WinRunner executes a TSL statement, it passes through the GUI Map before being sent to Windows
    • The application’s response must pass through the GUI Map also
    GUI Map
  • 24. Main Issues in Script Creation
    • Unique Identification of objects
      • WinRunner must uniquely identify each object in the Graphical User Interface (GUI) of the application
    • Naming of objects
      • How will WinRunner refer to GUI objects in the application? (&quot;Press the OK button in the Open window&quot;)
  • 25. How Does WinRunner Identify an Object? John ******* WinRunner uses an object’s physical attributes to identify the object Displayed label class MSW_class x y abs_x abs_y maximizable focused width height active MSW_id handle minimizable nchildren enabled TOOLKIT_class ATTRIBUTES
  • 26. How Does WinRunner Uniquely Identify an Object? John ******* WR uses the minimum number of static attributes to achieve unique identification label class Class: push_button Label: “OK”
  • 27. How Does WinRunner Assign Object Names? John ******* WinRunner assigns a short name to each object called the logical name Class: push_button Label: “OK” button_press (“ OK ”); edit_set (“ Name ”, “John”); edit_set (“ Password ”, “mercury”);
  • 28. Into Which Field Will WinRunner Play Back? set_window(&quot;Login&quot;, 10); edit_set (&quot;Name:&quot;, &quot;John&quot;); John ? ?
  • 29. Scope of Identification edit_set (&quot;Name:&quot;, &quot;John&quot;); John WinRunner identifies an object within the scope of its parent window (not the entire application) set_window (&quot;Login&quot;, 10);
  • 30. WinRunner Tracks AUT’s Windows and Objects With the GUI Map File
    • The GUI Map file contains the:
    • Windows of the AUT
    • Objects within each window
    • Physical attributes that create each object’s unique identification
    GUI Map File Name: Physical Description: Name class: edit attached_text: &quot;Name&quot; WINDOW: Login Password class: edit attached_text: &quot;Password&quot; OK class: push_button label: &quot;OK&quot;
  • 31. GUI Map Editor
    • Visual tree displays windows and objects contained in the GUI Map File
    • First level consists of all windows in AUT
    • Second level consists of objects uniquely identified within each parent window
    Parent Window (logical name) Physical Description of window or object highlighted above Child Objects (logical names)
  • 32. The GUI Map
    • Allows separation of physical attributes from test scripts
    • Enables WinRunner to uniquely identify objects in the AUT using physical attributes
    • Allows WinRunner to refer to objects in the script using an intuitive logical name
    • Provides the connection between logical names and physical attributes
    • Maintainability
      • If a button label changes in the application, update the button description once in the GUI map rather than in 500 tests
    • Readability
      • button_press(&quot;Insert&quot;) instead of button_press(&quot;{class: ThunderSSCommand}&quot;);
    • Portability
      • Use the same script for all platforms, with a different GUI map for each platform
    Characteristics Strengths
  • 33. GUI Map Translates Logical Names Into Physical Descriptions Options Class: Window Label: Window Dealer Name Class: Edit label: DealerName Address Class: Window Label: Address Login Class: Window Label: Login Automobile Purchase Form Class: Window Label: APF Customer Name Class: Edit label: CustomerName Make Class: Window Label: Make SCRIPT GUI MAP AUT set_window(&quot;Automobile Purchase Form&quot;, 10); edit_set (&quot;Address&quot;,&quot;234 Willow Drive&quot;); edit_set (&quot;Customer Name&quot;, &quot;Thomas Paine&quot;); Logical Name Physical Description
  • 34. Recording Example Application GUI Map Logical Physical { class: window, MSW_id: 3277 label: &quot;Save As&quot; } { class: push_button, label: &quot;OK&quot; } &quot;Save As&quot; &quot;OK&quot; set_window (&quot;Save As&quot;, 1); button_press (&quot;OK&quot;); Test Script WinRunner
  • 35. Playback Example
      • Save As
    Application GUI Map Logical Physical { class: window, MSW_id: 3277 label: &quot;Save As&quot; } { class: push_button, label: &quot;OK&quot; } &quot;Save As&quot; &quot;OK&quot; set_window (&quot;Save As&quot;, 1); button_press (&quot;OK&quot;); Test Script WinRunner
  • 36. Summary
    • WinRunner uniquely identifies every object in the AUT by its physical description
    • Each object is uniquely identified within the scope of its parent window (not the entire application)
    • WinRunner references each object in the script using a logical name
    • Objects and their descriptions are stored in a GUI Map File
    • The GUI Map File can be viewed in the GUI Map Editor
  • 37. Techniques For Managing GUI Map Files Technique 1 One GUI Map file per test Technique 2 One GUI Map file for many tests
  • 38. Object and Window Properties During Recording Name: Description: Date class: edit attached_text: &quot;Date&quot; set_window(&quot;Automobile Purchase Form&quot;, 10); list_select_item (&quot;Make&quot;, &quot;BMW&quot;); edit_set (&quot;Year&quot;, &quot;1973&quot;); edit_set(&quot;Model&quot;, &quot;2002tii&quot;); WINDOW: Automobile Purchase Form Year class: edit attached_text: &quot;Year&quot; Make class: list attached_text: &quot;Make&quot; Model class: edit attached_text: &quot;Model&quot; edit_set (&quot;Date&quot;, &quot;12/12/03&quot;); WinRunner stores the names and descriptions for windows and objects in a temporary GUI Map file Temporary GUI Map file Technique 1
  • 39. What Happens to These Properties? Use the GUI Map Editor to save the contents of the Temporary GUI Map file to a permanent GUI Map file Technique 1 Temporary GUI Map file Name: Description: Date class: edit attached_text: &quot;Date&quot; WINDOW: Automobile Purchase Form Year class: edit attached_text: &quot;Year&quot; Make class: list attached_text: &quot;Make&quot; Model class: edit attached_text: &quot;Model&quot;
  • 40. Creating a Permanent GUI Map File Car_App.gui L1 Car_App.gui Insert Test1 Test2 Testing Project Tests GUI Technique 1
  • 41. Adding New Windows and Objects to a GUI Map File Invoke the GUI Map Editor 1 Technique 1
  • 42. Adding New Windows and Objects to a GUI Map File Technique 1 Invoke the GUI Map Editor 1 Press the Expand Button to display Temporary and Permanent GUI Map files 2
  • 43. Adding New Windows and Objects to a GUI Map File Technique 1 Invoke the GUI Map Editor 1 Move contents of Temp to Permanent by pressing Move button 3 Press the Expand Button to display Temporary and Permanent GUI Map files 2
  • 44. Adding New Windows and Objects to a GUI Map File Technique 1 Save changes to permanent GUI Map file 4 Invoke the GUI Map Editor 1 Press the Expand Button to display Temporary and permanent GUI Map files 2 Move contents of Temp to permanent by pressing Move button 3
  • 45. Save Project GUI Map Files Together Insert Test1 Test2 Testing Project Tests Insert.gui L1 Insert.gui GUI Test1.gui Test2.gui Technique 1
  • 46. Techniques for Managing GUI Map Files Technique 1 One GUI Map file per test Technique 2 One GUI Map file for many tests
  • 47. Creating a Permanent GUI Map File Technique 2 Invoke the GUI Map Editor 1
  • 48. Creating a Permanent GUI Map File The cursor changes to a pointing hand Technique 2 Invoke the GUI Map Editor 1 Click the Learn Button 2
  • 49. Creating a Permanent GUI Map File The cursor changes to a pointing hand Technique 2 Invoke the GUI Map Editor 1 Click the Learn Button 2 Click on the Window to be learned 3
  • 50. Creating a Permanent GUI Map File The cursor changes to a pointing hand WinRunner learns all objects in window Technique 2 Invoke the GUI Map Editor 1 Click the Learn Button 2 Click on the Window to be learned 3
  • 51. Creating a Permanent GUI Map File The cursor changes to a pointing hand WinRunner learns all objects in window Technique 2 Invoke the GUI Map Editor 1 Click the Learn Button 2 Click on the Window to be learned 3 Repeat for all windows in the application 4
  • 52. Modify Names for Script Readability These names are unreadable. To what objects do they refer ? Technique 2
  • 53. Modify Names for Script Readability Technique 2 Highlight the object whose name you want to change 1
  • 54. Modify Names for Script Readability Technique 2 Highlight the object whose name you want to change 1 Click the Modify Button 2
  • 55. Modify Names for Script Readability Technique 2 Highlight the object whose name you want to change 1 Change the Logical Name of the object 3 Click the Modify Button 2 Click OK 4
  • 56. Modify Names for Script Readability &quot;Name:” appears in your test script during recording instead of &quot;ThunderRTTextBox_0&quot; RESULT ! Technique 2 Click OK 4 Highlight the object whose name you want to change 1 Change the Logical Name of the object 3 Click the Modify Button 2
  • 57. Creating a Permanent GUI Map File Car_App.gui L1 Car_App.gui Insert Test1 Test2 Testing Project Tests GUI Technique 2
  • 58. Which Technique Should You Use? Technique 1 Advantages 1. Each test has GUI Map file independence 2. There is no need for a GUI Map file administrator 3. The GUI Map file is very simple to create–record and save Preferred method if the application is not intended to change during renovation Technique 2 Advantages 1. Object and window names can be very readable in the test script 2. If an object or window description changes, you only have to modify one GUI Map file–all tests will play back properly Preferred method if the application might change during renovation
  • 59. Importance of the GUI Map File ? set_window(&quot;Automobile Purchase Form&quot;, 10); edit_set (&quot;Date&quot;, &quot;12/12/03&quot;); list_select_item (&quot;Make&quot;, &quot;BMW&quot;); edit_set (&quot;Year&quot;, &quot;1973&quot;); edit_set(&quot;Model&quot;, &quot;2002tii&quot;); edit_set (&quot;Purchase Price&quot;, &quot;20000.00&quot;); What happens when playback is attempted, and the proper GUI Map file is not loaded? Automobile Purchase Form Date
  • 60. Load GUI Map File from Script GUI_load(&quot;N:2K_ProjUInsert.gui&quot;); set_window(&quot;Automobile Purchase Form&quot;, 10); edit_set (&quot;Date&quot;, &quot;12/12/03&quot;); list_select_item (&quot;Make&quot;, &quot;BMW&quot;); edit_set (&quot;Year&quot;, &quot;1973&quot;); edit_set(&quot;Model&quot;, &quot;2002tii&quot;); edit_set (&quot;Purchase Price&quot;, &quot;20000.00&quot;); 12/12/03 BMW 1973 2002tii Insert.gui
  • 61. Unload GUI Map File from Script GUI_load(&quot;N:2K_ProjUInsert.gui&quot;); Insert.gui set_window(&quot;Automobile Purchase Form&quot;, 10); edit_set (&quot;Date&quot;, &quot;12/12/03&quot;); list_select_item (&quot;Make&quot;, &quot;BMW&quot;); edit_set (&quot;Year&quot;, &quot;1973&quot;); edit_set(&quot;Model&quot;, &quot;2002tii&quot;); edit_set (&quot;Purchase Price&quot;, &quot;20000.00&quot;); GUI_close_all( ); 12/12/03 BMW 1973 2002tii
  • 62. Fixing the GUI Map File set_window(&quot;Automobile Purchase Form&quot;, 10); edit_set (&quot;Date&quot;, &quot;12/12/03&quot;); list_select_item (&quot;Make&quot;, &quot;BMW&quot;); edit_set (&quot;Year&quot;, &quot;1973&quot;); edit_set(&quot;Model&quot;, &quot;2002tii&quot;); edit_set (&quot;Purchase Price&quot;, &quot;20000.00&quot;); GUI Map file Name: Description: Date class: edit MSW_id: 14
  • 63. Fixing the GUI Map File 2 set_window(&quot;Automobile Purchase Form&quot;, 10); edit_set (&quot;Date&quot;, &quot;12/12/03&quot;); list_select_item (&quot;Make&quot;, &quot;BMW&quot;); edit_set (&quot;Year&quot;, &quot;1973&quot;); edit_set(&quot;Model&quot;, &quot;2002tii&quot;); edit_set (&quot;Purchase Price&quot;, &quot;20000.00&quot;); 1 GUI Map file Name: Description: Date class: edit MSW_id: 14
  • 64. Use the GUI Map Editor to Fix File *L1 Insert.gui L1 Insert.gui Active GUI file: N:2K_ProjectUIinsert.gui Invoke the GUI Map Editor 1 Edit the description 3 Save the file 4 Highlight field and press Modify 2
  • 65. Fixing the GUI Map File 12/12 /03 set_window(&quot;Automobile Purchase Form&quot;, 10); edit_set (&quot;Date&quot;, &quot;12/12/03&quot;); list_select_item (&quot;Make&quot;, &quot;BMW&quot;); edit_set (&quot;Year&quot;, &quot;1973&quot;); edit_set(&quot;Model&quot;, &quot;2002tii&quot;); BMW 1973 2002tii ! Success WinRunner can now successfully playback the script
  • 66. Custom User Toolbar
    • The Custom User Toolbar feature allows you to customize WinRunner’s UI to suit your testing needs
    • Create shortcuts to frequently used WinRunner menu commands
    • Paste TSL statements into your test scripts
    • Execute TSL statements
  • 67. Add GUI Map Editor to the Custom User Toolbar An icon for each command selected is added to the User Toolbar Select Settings > Customize User Toolbar 1 In each category, select command(s) to appear in toolbar 2
  • 68. Summary
    • Two methods to manage GUI Map files
      • 1 GUI Map per test
        • if AUT is not expected to change
        • easiest way to create a GUI Map file
      • 1 GUI Map for many tests
        • if changes to AUT are expected
        • most easily maintained
    • Use the GUI Map Editor to fix GUI Map file problems
  • 69. LAB EXERCISE
  • 70.
    • Use GUI Spy to learn the objects
    • Record Flight Application Sample and Save the temporary GUI Map file and Load the same GUI Map file (Use function)
    • Create GUI Map for the same Using Learn option
    • Merge Login and Flight Application GUI Map file into a single one
    • Create a GUI Map File for Burger Application using the Learn option
  • 71. Day 3
    • Topic
    • Introduction to Verification
    • GUI Checkpoints
    • Database Checkpoints
    • Bitmap Checkpoints
    • Text Checkpoints
  • 72. Verification GUI Checkpoints Database Checkpoints Bitmap Checkpoints Text Checkpoints
  • 73. Verifying the AUT - Manual Testing PASS ? Step Step Description Expected Result 1 Select File > New SOFTWARE REQUIREMENT SPECIFICATIONS 2.3.2 Creating a New Order Once the end user selects File > New and enters their name, the &quot;Terms&quot; button is automatically enabled.
  • 74. Verifying the AUT - Manual Testing Step Step Description Expected Result William Frawley PASS ? 2 Enter your name The Terms button is enabled 1 Select File > New SOFTWARE REQUIREMENT SPECIFICATIONS 2.3.2 Creating a New Order Once the end user selects File > New and enters their name, the &quot;Terms&quot; button is automatically enabled.
  • 75. Verifying the AUT - Manual Testing Step Step Description Expected Result 2 Enter your name The Terms button is enabled 1 Select File > New William Frawley PASS ? SOFTWARE REQUIREMENT SPECIFICATIONS 2.3.2 Creating a New Order Once the end user selects File > New and enters their name, the &quot;Terms&quot; button is automatically enabled.
  • 76. Verifying the AUT - Automated Testing     William Frawley ? set_window (&quot;Automobile Purchase Form&quot;, 8); menu_select_item (&quot;File;New Form&quot;); edit_set (&quot;Customer Name&quot;, &quot;William Frawley&quot;); SOFTWARE REQUIREMENT SPECIFICATIONS 2.3.2 Creating a New Order Once the end user selects File > New and enters their name, the &quot;Terms&quot; button is automatically enabled.
  • 77. What Is WinRunner Verification? Definition: Verification is the process by which WinRunner reports whether expected results are actualized by the application.
  • 78. How WinRunner Verifies WinRunner compares the actual result to the stored, expected result 3 WinRunner captures an actual result during playback 2 1 WinRunner or the tester stores an expected result with the recorded test script WinRunner reports the comparison outcome as PASS or FAIL 4
  • 79. How Does a Checkpoint Work? 1 2 3 4 = X ? WinRunner WinRunner WinRunner WinRunner Pass Fail Test Report Expected AUT Actual Expected AUT Actual
  • 80. Process to Create Verification Run the recorded test script to verify correct execution 3 Test the checkpoint to ensure that it works for PASS and FAIL conditions 2 1 Capture or create the expected result within the recorded test script The tester creates the expected result only for text verification NOTE
  • 81. Playback - Run Modes
    • DEBUG To check for errors in the script (Results folder: debug )
    • VERIFY To test the application and verify the result (Results folder: res1 (default); user can rename)
    • UPDATE To overwrite the expected result with a new value (Results folder: exp )
  • 82. GUI Object Verification
    • Is the window the correct size?
    • Is the OK button enabled?
    • What is the content of the Name field?
    Check the state or attributes of GUI objects:
  • 83. Database Verification
    • Check the contents and dimensions of a database
    • Directly verify database-related transactions
  • 84. Bitmap Image Verification
    • Check non-GUI object areas of the application by capturing a bitmap
    • Capture bitmap of window, object, or area of screen
  • 85. Text Verification
    • Read and verify text from bitmap areas or non-GUI object based interfaces (e.g., ASCII)
  • 86. Summary
    • Verification allows WinRunner to check the AUT's behavior
    • Types of verification checks
      • GUI objects
      • databases
      • bitmap images
      • text
    • Use GUI Object verification whenever possible, because it is the most reliable
  • 87. Verification GUI Checkpoints Database Checkpoints Bitmap Checkpoints Text Checkpoints
  • 88. How Does GUI Checkpoints Work ? 1 2 3 4 = X ? WinRunner WinRunner WinRunner WinRunner Pass Fail Test Report Expected Actual Expected Actual AUT AUT
  • 89. Process for GUI checkpoints Test the Checkpoint to ensure that it works for ‘Pass’ & ‘Fail’ conditions 3 Create GUI checkpoint 2 1 Determine the visual cue(s) Run the recorded Test Script to verify correct execution 4
  • 90. Process for GUI checkpoints 1 Determine the visual cue(s)
  • 91. Which visual cues demonstrate that the AUT meets requirements
    • Flight Reservation Order information form
    • On click of Insert Order
    • … a visual cue is given by the application
    Application returns a message Application returns a value Object changes its state GUI object example
  • 92. Determine which visual cues to verify ?
    • Edit Field
      • Compare
      • Enabled
      • Focus
      • Range
    • Check Button
      • Enabled
      • Focus
      • Label
    • Pushbutton
      • Enabled
      • Focus
      • Label
      • Width
      • Height
  • 93. Checkpoint differs depending on the object to be verified Win_check_info Window Obj_check_info Generic Object button_check_info Button(check,radio,push) list_check_info List Checkpoint function Type of Object
  • 94. Process for GUI checkpoints Create GUI checkpoint 2 1 Determine the visual cue(s)
  • 95. Create GUI Checkpoints
    • Select Checkpoint to fit the verification
    State, Label Enabled, Focus Multiple properties of multiple objects Enabled, Label Multiple properties of one object Enabled One property of one object Example Type of GUI Checkpoint
  • 96. Check One property of one Object
    • Select GUI Checkpoint for single property
    set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
  • 97. Check One property of one Object
    • Select GUI Checkpoint for single property
    button_check_info (“OK”,”enabled”,0);
    • Point to the Object
    • WinRunner inserts button_check_info statement into the recorded Test Script
    set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
  • 98. Check Multiple properties of one Object
    • Select GUI Checkpoint for Object/Window
    set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
  • 99. Check Multiple properties of one Object
    • Select GUI Checkpoint for Object/Window
    obj_check_gui ( &quot;OK&quot; , &quot;list1.ckl&quot; , &quot;gui1&quot; , 1 );
    • Point to the Object
    • Select Multiple properties for the objects
    set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
  • 100. Check Multiple properties of one Object
    • Select GUI Checkpoint for Object/Window
    obj_check_gui ( &quot;OK&quot; , &quot;list1.ckl&quot; , &quot;gui1&quot; , 1 );
    • Point to the Object
    • Select Multiple properties for the objects
    • WinRunner inserts a obj_check_gui statement
    set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
  • 101. Check Multiple properties of multiple Objects
    • Select GUI Checkpoint for Multiple Objects
    set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
  • 102. Check Multiple properties of multiple Objects
    • Select GUI Checkpoint for Multiple Objects
    • Click Add and point to the object
    set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
  • 103. Check Multiple properties of multiple Objects
    • Select GUI Checkpoint for Multiple Objects
    • Click Add and point to the object
    • Select Multiple properties for multiple objects
    set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
  • 104. Check Multiple properties of multiple Objects
    • Select GUI Checkpoint for Multiple Objects
    win_check_gui ( &quot;Login&quot; , &quot;list2.ckl&quot; , &quot;gui2&quot; , 1 );
    • Point to the Object
    • Select Multiple properties for multiple objects
    • WinRunner inserts a win_check_gui statement
    set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
  • 105. Process for GUI checkpoints Test the Checkpoint to ensure that it works for ‘Pass’ & ‘Fail’ conditions 3 Create GUI checkpoint 2 1 Determine the visual cue(s)
  • 106. Test the checkpoint
    • Checkpoint should work for both ‘Pass’ and ‘Fail’ condition
    • Set the object to a state that should ‘Pass’
    • Step through the checkpoint in Debug mode
    • Set the object to a state that should ‘Fail’ (Reverse the object state)
    • Step through the checkpoint again
    • Verify correct execution
  • 107. Process for GUI checkpoints Test the Checkpoint to ensure that it works for ‘Pass’ & ‘Fail’ conditions 3 Create GUI checkpoint 2 1 Determine the visual cue(s) Run the recorded Test Script to verify correct execution 4
  • 108. Verify correct Script Execution
    • After successfully testing the Checkpoints for ‘Pass’ and ‘Fail’ conditions
    • We are ready to run the entire Script
    • Script should run without error
    • When Script is ok, we are ready to test the application under test (AUT)
  • 109. Test directory after GUI Checkpoint Testing Project Tests chklist List1.ckl exp Test2 gui1.chk Test1 Test2
  • 110. Summary
    • GUI Checkpoint can verify
      • One property of one object
      • Multiple properties of one objects
      • One or more properties of several objects
    • Expected results are stored in exp folder
    • Actual results are stored in results folder
  • 111. Verification GUI Checkpoints Database Checkpoints Bitmap Checkpoints Text Checkpoints
  • 112. Database Checkpoint Definition: A test script checkpoint which verifies the schema table contains the expected data
  • 113. Flight Database Schema Flight_Number (FK) Order_Number (PK) Orders Flight_Number (PK) Flight A Foreign Key value in a table must exist as a Primary Key value in a referenced table or be null Referential Integrity
  • 114. Queries Extract Data
    • Select Order_Number from Orders Where Flight_Number = ‘19075’
    11 Order_Number
  • 115. Why use Database Checkpoints ?
    • Does the AUT insert , update and delete records correctly
    • Do the new versions of the database function properly
    • Does the AUT maintain referential integrity
  • 116. What can you check in a Database ?
    • No of Columns
    • No of Rows
    • Data content of the tables
  • 117. How does WinRunner Query the Data ?
    • WinRunner integrates with MS Query or a Data Junction
    • MS Query is used to create a query to extract data
    • The query is used by WinRunner to capture the expected and actual values from the table(s)
  • 118. How Does Database Checkpoint Work ? 1 2 3 4 = X ? WinRunner WinRunner WinRunner WinRunner Pass Fail Test Report Expected Actual Expected Actual AUT AUT
  • 119. Process for Database Checkpoints Test the condition to ensure that it works for Pass and Fail conditions 3 Use Database Checkpoint wizard to implement the Database Checkpoint 2 1 Record User actions to create database transaction Run the recorded scripts 4
  • 120. Process for Database Checkpoints 1 Record User actions to create database transaction
  • 121. Record user actions to create a Database transaction edit_set ( &quot;Name:&quot; , &quot;Preeti&quot; ); button_press ( &quot;Insert Order&quot; ); Preeti set_window ( &quot;Flight Reservation&quot; , 7 ); edit_set ( &quot;Date of Flight:&quot; , &quot;09/06/02&quot; );
  • 122. Process for Database Checkpoints Use Database Checkpoint wizard to implement the database checkpoint 2 1 Record User actions to create database transaction
  • 123. Use Database Checkpoint Wizard
    • Select Database Checkpoint for default check
    set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
  • 124. Use Database Checkpoint Wizard
    • Select Database Checkpoint for default check
    • Create a Query to extract data
  • 125. Use Database Checkpoint Wizard
    • Select Database Checkpoint for default check
    db_check ( &quot;list1.cdl&quot; , &quot;dbvf1&quot; );
    • Create a Query to extract data
    • WinRunner inserts a db_check statement
    set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
  • 126. Process for Database checkpoints Test the condition to ensure that it works for Pass and Fail conditions 3 Use Database Checkpoint wizard to implement the database checkpoint 2 1 Record User actions to create database transaction
  • 127. Test the checkpoint
    • Checkpoint should work for both ‘Pass’ and ‘Fail’ condition
    • Set the database to a state that should ‘Pass’
    • Step through the checkpoint in Debug mode
    • Set the database to a state that should ‘Fail’ (Reverse the object state)
    • Step through the checkpoint again
    • Verify correct execution
  • 128. Process for Database checkpoints Test the Checkpoint to ensure that it works for ‘Pass’ & ‘Fail’ conditions 3 Use Database Checkpoint wizard to implement the database checkpoint 2 1 Record User actions to create database transaction Run the recorded scripts 4
  • 129. Verify correct Script Execution
    • After successfully testing the Checkpoints for ‘Pass’ and ‘Fail’ conditions
    • We are ready to run the entire Script
    • Script should run without error
    • When Script is ok, we are ready to test the application under test (AUT)
  • 130. Test directory after Database Checkpoint Testing Project Tests chklist list1.cdl msqr1.sql exp Test2 dbvf1 Test1 Test2
  • 131. Summary
    • Use Database Checkpoints to verify data in the Database
    • Use MS Query to extract data
    • WinRunner uses Query to capture expected and Actual results
    • Always restore the database to its original state before each Test execution
  • 132. Verification GUI Checkpoints Database Checkpoints Bitmap Checkpoints Text Checkpoints
  • 133. Bitmap Checkpoint Definition:
    • Bitmap checkpoint are non–context sensitive and are dependent upon the screen resolution
    • Color scheme (screen resolution and no of colors)
    Use Bitmap checkpoint only when verification cannot be accomplished using object or window attributes Tip
  • 134. Is Bitmap Checkpoint necessary? Bitmap Checkpoint GUI Checkpoint
    • Used to verify non-GUI Object areas e.g. Drawing Area
    • When unable to use GUI Checkpoint
    • Useful for Graphs etc.
    • Most Reliable
    • Maintainable
    • Preferred method for buttons etc.
  • 135. How Does Bitmap Checkpoint Work ? 1 2 3 4 = X ? WinRunner WinRunner WinRunner WinRunner Pass Fail Test Report Expected Actual Expected Actual AUT AUT
  • 136. Process for Bitmap Checkpoints Test the condition to ensure that it works for Pass and Fail conditions 3 Create a Bitmap Checkpoint in the recorded Test Script 2 1 Is Bitmap verification necessary If yes verify screen area or object/window? Run the recorded scripts Differences are reported in Test Results and the difference Bitmap is found 4
  • 137. Process for Bitmap Checkpoints Create a Bitmap Checkpoint in the recorded Test Script 2 1 Is Bitmap verification necessary If yes verify screen area or object/window?
  • 138. Create a Bitmap Checkpoint
    • Create a Bitmap Checkpoint for Object/Window or a Screen Area
    set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
  • 139. Create a Bitmap Checkpoint
    • Create a Bitmap Checkpoint for Object/Window or a Screen Area
    • Point to the object
  • 140. Create a Bitmap Checkpoint
    • Create a Bitmap Checkpoint for Object/Window or a Screen Area
    obj_check_bitmap ( &quot;Name:&quot; , &quot;Img1&quot; , 1 );
    • Point to the Object
    • WinRunner inserts a obj_check_bitmap statement
    set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
  • 141. Process for Bitmap Checkpoints Test the condition to ensure that it works for Pass and Fail conditions 3 Create a Bitmap Checkpoint in the recorded Test Script 2 1 Is Bitmap verification necessary If yes verify screen area or object/window?
  • 142. Test the checkpoint
    • Checkpoint should work for both ‘Pass’ and ‘Fail’ condition
    • Set the object to a state that should ‘Pass’
    • Step through the checkpoint in Debug mode
    • Set the object to a state that should ‘Fail’ (Reverse the object state)
    • Step through the checkpoint again
    • Verify correct execution
  • 143. Verify correct Script Execution
    • After successfully testing the Checkpoints for ‘Pass’ and ‘Fail’ conditions
    • We are ready to run the entire Script
    • Script should run without error
    • When Script is ok, we are ready to test the application under test (AUT)
  • 144. Process for Bitmap Checkpoints Test the Checkpoint to ensure that it works for ‘Pass’ & ‘Fail’ conditions 3 Create a Bitmap Checkpoint in the recorded Test Script 2 1 Is Bitmap verification necessary If yes verify screen area or object/window? Run the recorded scripts Differences are reported in Test Results and the difference Bitmap is found 4
  • 145. Differences are reported and the difference Bitmap is found
    • Expected Result
    Actual Result Difference Bitmap
  • 146. Summary
    • Use Bitmap checkpoint for non GUI objects
    • You can define specific area of bitmap to verify
    • WinRunner captures a difference bitmap when checkpoint fails
    • Use GUI checkpoint whenever possible
  • 147. Verification GUI Checkpoints Database Checkpoints Bitmap Checkpoints Text Checkpoints
  • 148. Why use a Text Checkpoint ?
    • Verify range of values
    • Calculate dynamic values
    • Branch a test according to the value read from the screen
    • Color, Font and Resolution independent
    • Reliable, Portable and Maintainable
  • 149. Process for Text Checkpoints Insert code to compare the actual and expected value 3 Insert a function to read the actual text from the AUT during playback 2 1 Define a variable in the script and assign the expected value Insert code to report the comparison outcome to WinRunner Test Results window 4
  • 150. Process for Text Checkpoints 1 Define a variable in the script and assign the expected value
  • 151. Define a variable in the script and assign the expected value
    • for e.g. tickets_sold =“Total tickets sold is 26”
  • 152. Process for Text Checkpoints Insert a function to read the actual text from the AUT during playback 2 1 Define a variable in the script and assign the expected value
  • 153. Insert a function to read the actual text from the AUT during playback
    • There are three ways to insert functions depending on the Text type
    • If Text is ….
    Attribute of Standard or a Custom Object Part of custom GUI object which cannot be read as an attribute Bitmap obj_get_info obj_get_text win_get_text
  • 154. Process for Text Checkpoints Insert code to compare the actual and expected value 3 Insert a function to read the actual text from the AUT during playback 2 1 Define a variable in the script and assign the expected value
  • 155. Insert code to compare the actual and expected value
    • set_window(&quot;Graph&quot;, 1); obj_get_text(&quot;GS_Drawing&quot;, text);
    • if (text == &quot;Total Tickets Sold is 26&quot; ) report_msg(“Message is correct&quot;); else report_msg(“Message is not correct&quot;);
  • 156. Process for Text Checkpoints Insert code to compare the actual and expected value 3 Insert a function to read the actual text from the AUT during playback 2 1 Define a variable in the script and assign the expected value Insert code to report the comparison outcome to WinRunner Test Results window 4
  • 157. LAB EXERCISE
  • 158.
    • In the “Burger Application” check whether Medium Burger,Medium French French Fries and Apple juice are selected by using GUI checkpoints .Change the defaults and press Reset button.Ensure that Reset is functioning properly by using GUI checkpoints.
    • Create a Bitmap checkpoint on Order No and Graph of Flight Reservation
    • Create a text checkpoint on any of page and verify the results .Search for “Sample “ word in the application using text checkpoint.
    • Create a database checkpoint to check whether a record is inserted or not by adding checkpoint on Order No
  • 159. Data Driven Tests
  • 160. Data-Driven Tests
    • In this lesson you will learn:
    • What is a data-driven test
    • How to work with Data Tables
    • How to implement a data-driven test
    • How to import data from a database
  • 161. What is a Data-Driven Test?
    • A test contains:
    • Actions: list_select_item(&quot;Fly From:&quot;,&quot;Denver&quot;);
    • Objects: list_select_item(&quot;Fly From:&quot;,&quot;Denver&quot;);
    • Data: list_select_item(&quot;Fly From:&quot;,&quot;Denver&quot;);
    What if you want to use different data? San Francisco Los Angeles London
  • 162. What is a Data-Driven Test?
    • Data-driven test:
    • Test is modified to read data from the Data Table
    • Data is entered in the Data Table
    “ Denver” ); Objects
      • list_select_item ( &quot;Fly From:”,
    Recorded Value Actions Data Table ddt_val (table, fly_from) ); Data
  • 163. What Is the Data Table? The Data Table is a spreadsheet file in WinRunner that stores the input values you will use to data-drive your test . Definition:
  • 164. Advantages of a Data-Driven Test
    • Run the same test with different data
    • Expandable
    • Easy to maintain
  • 165. Data Driving Tests Create a test 1 Modify test to read from Data Table 2 3 Move data to Data Table 1. Create test with data 2. Verify script is ready for data driving Create a test
  • 166. 1. Create a Test Create Test with Data invoke_application(“flight1a.exe&quot;,&quot;&quot;,&quot;C:amp;quot;,SW_SHOW); set_window (&quot;Login&quot;, 10); edit_set (&quot;userid&quot;, &quot;Josephine&quot;); password_edit_set (&quot;password&quot;, “kxpvnwoulxjuax” ); button_press (&quot;OK&quot;); set_window (&quot;Flight Reservation&quot;, 10); win_check_gui(&quot;Flight Reservation&quot;, &quot;list1.ckl&quot;, &quot;gui1&quot;, 1); menu_select_item (&quot;File;Exit&quot;); Test Script
  • 167. 1. Create a Test Verify that Script Is Ready to Data Drive invoke_application(“flight1a.exe&quot;,&quot;&quot;,&quot;C:amp;quot;,SW_SHOW); set_window (&quot;Login&quot;, 10); edit_set (&quot;userid&quot;, &quot;Josephine&quot;); password_edit_set (&quot;password&quot;, “kxpvnwoulxjuax” ); button_press (&quot;OK&quot;); set_window (&quot;Flight Reservation&quot;, 10); win_check_gui(&quot;Flight Reservation&quot;, &quot;list1.ckl&quot;, &quot;gui1&quot;, 1); menu_select_item (&quot;File;Exit&quot;); Does the script verify the expected results? Are all actions that involve inputting data recorded into the script? Are all synchronization points entered into the script? Are the initial and end conditions the same? ? Test Script
  • 168. Data Driving Tests Create a test 1 Move data to Data Table 3 Modify test to read from Data Table 2 Modify test to read from Data Table 1. Run DataDriver Wizard
  • 169. The DataDriver Wizard will convert your baseline script table = &quot;default.xls&quot; ; rc = ddt_open (table, DDT_MODE_READ); if (rc!= E_OK && rc != E_FILE_OPEN) pause ( &quot;Cannot open table.&quot; ); ddt_get_row_count (table,table_RowCount); for (table_Row = 1 ; table_Row <= table_RowCount; table_Row ++) { ddt_set_row (table,table_Row); invoke_application ( &quot;D:light1a.exe&quot; , &quot;&quot; , &quot;&quot; ,SW_SHOW); set_window ( &quot;Login&quot; , 10 ); edit_set ( &quot;Agent Name:&quot; , ddt_val (table, &quot;Agent_Name&quot; )); password_edit_set ( &quot;Password:&quot; , ddt_val (table, &quot;Password&quot; )); button_press ( &quot;OK&quot; ); set_window ( &quot;Flight Reservation&quot; , 22 ); menu_select_item ( &quot;File;Exit&quot; ); } ddt_close (table); so that it will: 2. Modify Test to Read from Data Table What Does the DataDriver Do? Open the Data Table and check that it was successfully opened 1 invoke_application ( &quot;D:light1a.exe&quot; , &quot;&quot; , &quot;&quot; ,SW_SHOW); set_window ( &quot;Login&quot; , 10 ); edit_set ( &quot;Agent Name:&quot; , &quot;Catherine&quot; ); password_edit_set ( &quot;Password:&quot; , &quot;kzptnyoslzjsaz&quot; ); button_press ( &quot;OK&quot; ); set_window ( &quot;Flight Reservation&quot; , 22 ); menu_select_item ( &quot;File;Exit&quot; );
  • 170. Open the Data Table and check that it was successfully opened 1 table = &quot;default.xls&quot; ; rc = ddt_open (table, DDT_MODE_READ); if (rc!= E_OK && rc != E_FILE_OPEN) pause ( &quot;Cannot open table.&quot; ); ddt_get_row_count (table,table_RowCount); for (table_Row = 1 ; table_Row <= table_RowCount; table_Row ++) { ddt_set_row (table,table_Row); invoke_application ( &quot;D:light1a.exe&quot; , &quot;&quot; , &quot;&quot; ,SW_SHOW); set_window ( &quot;Login&quot; , 10 ); edit_set ( &quot;Agent Name:&quot; , ddt_val (table, &quot;Agent_Name&quot; )); password_edit_set ( &quot;Password:&quot; , ddt_val (table, &quot;Password&quot; )); button_press ( &quot;OK&quot; ); set_window ( &quot;Flight Reservation&quot; , 22 ); menu_select_item ( &quot;File;Exit&quot; ); } ddt_close (table); The DataDriver Wizard will convert your baseline script so that it will: 2. Modify Test to Read from Data Table What Does the DataDriver Do? Add a loop to read through all your data rows 2
  • 171. table = &quot;default.xls&quot; ; rc = ddt_open (table, DDT_MODE_READ); if (rc!= E_OK && rc != E_FILE_OPEN) pause ( &quot;Cannot open table.&quot; ); ddt_get_row_count (table,table_RowCount); for (table_Row = 1 ; table_Row <= table_RowCount; table_Row ++) { ddt_set_row (table,table_Row); invoke_application ( &quot;D:light1a.exe&quot; , &quot;&quot; , &quot;&quot; ,SW_SHOW); set_window ( &quot;Login&quot; , 10 ); edit_set ( &quot;Agent Name:&quot; , ddt_val (table, &quot;Agent_Name&quot; )); password_edit_set ( &quot;Password:&quot; , ddt_val (table, &quot;Password&quot; )); button_press ( &quot;OK&quot; ); set_window ( &quot;Flight Reservation&quot; , 22 ); menu_select_item ( &quot;File;Exit&quot; ); } ddt_close (table); Open the Data Table and check that it was successfully opened 1 The DataDriver Wizard will convert your baseline script so that it will: 2. Modify Test to Read from Data Table What Does the DataDriver Do? Add a loop to read through all your data rows 2 Parameterize data values so that it reads from the Data Table 3
  • 172. 2. Modify Test to Read from Data Table What Does the DataDriver Do? table = &quot;default.xls&quot; ; rc = ddt_open (table, DDT_MODE_READ); if (rc!= E_OK && rc != E_FILE_OPEN) pause ( &quot;Cannot open table.&quot; ); ddt_get_row_count (table,table_RowCount); for (table_Row = 1 ; table_Row <= table_RowCount; table_Row ++) { ddt_set_row (table,table_Row); invoke_application ( &quot;D:light1a.exe&quot; , &quot;&quot; , &quot;&quot; ,SW_SHOW); set_window ( &quot;Login&quot; , 10 ); edit_set ( &quot;Agent Name:&quot; , ddt_val (table, &quot;Agent_Name&quot; )); password_edit_set ( &quot;Password:&quot; , ddt_val (table, &quot;Password&quot; )); button_press ( &quot;OK&quot; ); set_window ( &quot;Flight Reservation&quot; , 22 ); menu_select_item ( &quot;File;Exit&quot; ); } ddt_close (table); Open the Data Table and check that it was successfully opened 1 The DataDriver Wizard will convert your baseline script so that it will: Add a loop to read through all your data rows 2 Parameterize data values so that it reads from the Data Table 3 Close the Data Table 4
  • 173. 2. Modify Test to Read from Data Table Running the DataDriver Wizard invoke_application(“flight1a.exe&quot;,&quot;&quot;,&quot;C:amp;quot;,SW_SHOW); set_window (&quot;Login&quot;, 10); edit_set (&quot;userid&quot;, ”Catherine&quot;); password_edit_set (&quot;password&quot;, “kxpvnwoulxjuax” ); button_press (&quot;OK&quot;); set_window (&quot;Flight Reservation&quot;, 10); win_check_gui(&quot;Flight Reservation&quot;, &quot;list1.ckl&quot;, &quot;gui1&quot;, 1); menu_select_item (&quot;File;Exit&quot;); 1. Highlight area you want to be data driven. 2. Start the DataDriver Wizard. invoke_application(“flight1a.exe&quot;,&quot;&quot;,&quot;C:amp;quot;,SW_SHOW); set_window (&quot;Login&quot;, 10); edit_set (&quot;userid&quot;, ”Catherine&quot;); password_edit_set (&quot;password&quot;, “kxpvnwoulxjuax” ); button_press (&quot;OK&quot;); set_window (&quot;Flight Reservation&quot;, 10); win_check_gui(&quot;Flight Reservation&quot;, &quot;list1.ckl&quot;, &quot;gui1&quot;, 1); menu_select_item (&quot;File;Exit&quot;); 1 2
  • 174. 2. Modify Test to Read from Data Table Running the DataDriver Wizard Final Result table = &quot; default.xls &quot;; rc = ddt_open( table , DDT_MODE_READ); if (rc!= E_OK && rc != E_FILE_OPEN) pause(&quot;Cannot open table.&quot;); ddt_get_row_count( table , table_RowCount); for(table_Row = 1; table_Row <= table_RowCount; table_Row ++) { ddt_set_row( table ,table_Row); invoke_application(&quot;D:light1a.exe&quot;,&quot;&quot;,&quot;&quot;,SW_SHOW); set_window (&quot;Login&quot;, 10); edit_set (&quot;Agent Name:&quot;,ddt_val( table ,&quot;Agent_Name&quot;)); password_edit_set(&quot;Password:&quot;,ddt_val( table ,&quot;Password&quot;)); button_press (&quot;OK&quot;); set_window (&quot;Flight Reservation&quot;, 22); menu_select_item (&quot;File;Exit&quot;); } ddt_close( table );
  • 175. 2. Modify Test to Read from Data Table Running the DataDriver Wizard Where does the Data Table reside? <test name> default.xls
  • 176. 2. Modify Test to Read from Data Table Running the DataDriver Wizard How do you populate the Data Table?
    • If you want to import data from a database, do it now, using the Wizard
    • Other methods will be discussed in the next section, “Move Data”
  • 177. 3. Move Data to Data Table Importing Data From Database to Data Table Database
  • 178. 3. Move Data to Data Table Importing Data From Database to Data Table Database
  • 179. 2. Modify Test to Read from Data Table Running the DataDriver Wizard edit_set (&quot;Agent Name:&quot;, “Catherine”); ? Final Result edit_set(“Agent Name:”, ddt_val(table,”Agent_Name”) );
  • 180. 2. Modify Test to Read from Data Table Running the DataDriver Wizard
  • 181. Data Driving Tests Create a test 1 2 3 Move data to Data Table Modify test to read from Data Table
  • 182. 3. Move Data to Data Table How Is Data Moved to Data Table?
    • Import, using DataDriver Wizard (covered in previous section)
    • Manually
    • Dynamically, during run time
  • 183. 3. Move Data to Data Table Insert Data Manually Open the Data Table 1 Enter Data you want to test 2 Close Data Table and save script 3
  • 184. 3. Move Data to Data Table Add Data Dynamically During Run Create Invoice Test 1 mer InvoiceNum 3421 yelet phine Data Table 3423 3423 3423 . . . . . . ddt_set_val(... Update Invoice Test 2 . . . . . . edit_set(...,ddt_val ...
  • 185. 3. Move Data to Data Table Add Data Dynamically During Run Add column to Data Table for data to be added 1
  • 186. 3. Move Data to Data Table Add Data Dynamically During Run table = &quot;default.xls&quot;; rc = ddt_open(table, DDT_MODE_READ); if (rc!= E_OK && rc != E_FILE_OPEN) pause(&quot;Cannot open table.&quot;); ddt_get_row_count(table,table_RowCount); for(table_Row = 1; table_Row <= table_RowCount; table_Row ++) { ddt_set_row(table,table_Row); set_window (&quot;Automobile Purchase Form&quot;, 2); edit_set (&quot;Customer Name&quot;,ddt_val(table,&quot;Customer_Name&quot;)); edit_set(&quot;Address:&quot;,ddt_val(table,&quot;Address&quot;)); edit_set (&quot;License&quot;,ddt_val(table,&quot;License&quot;)); obj_mouse_click (&quot;Method of Payment&quot;, 23, 13, LEFT); button_set (ddt_val(table,&quot;Cash&quot;), ON); list_select_item (&quot;Make&quot;,ddt_val(table,&quot;Make&quot;)); # Item Number 0; edit_set (&quot;Model&quot;,ddt_val(table,&quot;Model&quot;)); button_press (&quot;Insert Sale&quot;); edit_wait_info(&quot;StatusBar&quot;,&quot;value&quot;,&quot;New Purchase Completed Successfully...&quot;,10); } ddt_close(table); Add column to Data Table for data to be added 1 ddt_set_val ( table , “ ”, InvoiceNumber ); obj_get_info (&quot;Invoice No:&quot;,&quot;label&quot;, InvoiceNumber ); ddt_save ( table ); Modify the script so that it: 2 captures the data and saves it to a variable a sets the value in the Data Table b saves changes to the Data Table c Data Table InvoiceNo
  • 187. Summary
    • Create a “template” test with single set of data
    • Modify test to read data from table
      • run the Data Driver Wizard
    • Move data to Data Table
      • import data from a database
      • edit Data Table directly
      • add data to Data Table during run-time
  • 188. Exercise
  • 189.
    • Create a Data Driven test on Login and Password and Error Messages that it can generate.
    • Create Data Driven test on Customer Name field.
  • 190. Lesson Objectives
    • In this section, we will learn
    • the importance of synchronization for successful test playback
    • how to select the appropriate synchronization type for your script
    • how to insert synchronization into a test script
  • 191. How Do Client-Server Applications Behave? Single User Database server Server response time:
  • 192. How Do Client-Server Applications Behave? Several Users Database server Server response time:
  • 193. How Do Client-Server Applications Behave? Many Users Database server Server response time:
  • 194. How Do Client-Server Applications Behave? Example Response Times RESPONSE TIME Several users 0.61 Many users 1.00 Single user 0.33
  • 195. Complete the Business Process Manually Database 07/07/01 Los Angeles Denver Cash Enter 07/07/01 on Date field Select LA from Fly From field Select Denver from Fly To field Enter Cash as Method of Payment Press Flights button Example steps
  • 196. Complete the Business Process Manually Database Enter 07/07/01 on Date field Select LA from Fly From field Select Denver from Fly To field Enter Cash as Method of Payment Press Flights button Select a flight Example steps
  • 197. Complete the Business Process Manually Database 07/07/01 Los Angeles Denver Cash Errol Flynn Enter Customer Name Insert Order Wait for response before continuing Enter 07/07/01 on Date field Select LA from Fly From field Select Denver from Fly To field Enter Cash as Method of Payment Press Flights button Select a flight 7328 Close application Example steps
  • 198. Manual Steps Recorded in the Test Script edit_set (&quot;Date&quot;,&quot;070701&quot;); list_select_item ( &quot;Fly From:&quot;, &quot;Los Angeles&quot; ); list_select_item (&quot;Fly To:&quot;, &quot;Denver&quot;); list_select_item (&quot;Payment:&quot;, &quot;Cash&quot; ); button_press ( &quot;Flights&quot; ); button_press ( &quot;Insert Order&quot; ); ??? Enter 07/07/01 on Date field Select LA from Fly From field Select Denver from Fly To field Enter Cash as Method of Payment Press Flights button Enter Customer Name Insert Order Wait for response before continuing Select a flight win_close ( &quot;Flight Reservation&quot; ); Close the application set_window ( &quot;Flights Table&quot; , 4); button_press ( &quot;OK&quot; ); Example steps edit_set ( &quot;Customer Name:&quot; , &quot;Errol Flynn&quot; ); set_window ( &quot;Flight Reservation&quot; , 10);
  • 199. Why Not Insert a Wait Statement? button_press ( &quot;Insert Order&quot; ); win_close ( &quot;Flight Reservation&quot; ); wait ( ); 10 50 users 5.1 seconds 500 users 9.5 seconds 1 user 3.7 seconds AVERAGE RESPONSE TIMES
  • 200. Why Not Insert a Wait Statement? AUT 11.3 seconds RUN #1 Wait (10); button_press ( &quot;Insert Order&quot; ); win_close ( &quot;Flight Reservation&quot; ); wait ( ); 10 button_press ( &quot;Insert Order&quot; ); win_close ( &quot;Flight Reservation&quot; ); wait ( ); 15 PROBLEM: Test run failed because wait didn't last long enough SOLUTION: Add 50% to wait time as safety cushion
  • 201. Why Not Insert a Wait Statement? AUT 5.5 seconds RUN #2 Wait (15); 15 seconds button_press ( &quot;Insert Order&quot; ); win_close ( &quot;Flight Reservation&quot; ); wait ( ); 15 PROBLEM: Most of the wait time was unnecessary SOLUTION: Don't use a wait statement – use something that will continue as soon a s the AUT is finished. But what will do that? button_press ( &quot;Insert Order&quot; ); win_close ( &quot;Flight Reservation&quot; ); ???
  • 202. What Is a Synchronization Point? A synchronization point is a line in the test script that instructs WinRunner to wait for a certain response from the application during playback, just as a real user would. Definition:
  • 203. ADD SYNCHRONIZATION POINTS Introduction to Synchronization Add Synchronization Points Record user actions in script 1 Synchronize script to application under test 2 Add verification statements to check AUT 3 Run test or suite of tests 4
  • 204. Process to Add Synchronization Points Add Synchronization Points Establish visual cues to synchronize 1 Determine type of synchronization point 2 Add synchronization point to test script 3 Play back revised script 4
  • 205. Establish Visual Cue to Synchronize Examples 1 Wait for a bitmap to refresh BITMAP Wait for a window WINDOW Wait for an object state OBJECT STATE
  • 206. Methods of Synchronization obj_wait_info (&quot;Bar&quot;,&quot;label&quot;, &quot;Insert Done...&quot;, 20); Wait for an object state/property value obj_wait_bitmap (&quot;Window&quot;, &quot;Img1&quot;, 10, 209, 170, 81, 20 ); Wait for a bitmap set_window (&quot;Flight Reservation&quot;, 20); Wait for a window
  • 207. Determine Type of Synchronization (Waiting for a Window) 2 Window name Time set_window (&quot;Flight Reservation&quot;, 20); Wait for main window to appear after login
  • 208. Properties of Standard GUI Objects (Examples) Boolean Values 0 = False 1 = True State 3 State 2 State 1 class: push_button, focused: 1, label: &quot;Insert Order&quot;, enabled: 1 class: push_button, focused: 0, label: &quot;Insert Order&quot;, enabled: 1 class: push_button, focused: 0, label: &quot;Insert Order&quot;, enabled: 0
  • 209. Properties of Standard GUI Objects (Examples) Boolean Values 0 = False 1 = True State 3 State 2 State 1 class: list, focused: 1, value: &quot;Paris&quot; class: list, focused: 0, value: &quot;Los Angeles&quot; class: list, focused: 0, value: &quot;&quot; class: push_button, focused: 1, label: &quot;Insert Order&quot;, enabled: 1 class: push_button, focused: 0, label: &quot;Insert Order&quot;, enabled: 1 class: push_button, focused: 0, label: &quot;Insert Order&quot;, enabled: 0
  • 210. Properties of Standard GUI Objects (Examples) Boolean Values 0 = False 1 = True State 3 State 2 State 1 class: list, focused: 1, value: &quot;Paris&quot; class: list, focused: 0, value: &quot;Los Angeles&quot; class: list, focused: 0, value: &quot;&quot; class: push_button, focused: 1, label: &quot;Insert Order&quot;, enabled: 1 class: push_button, focused: 0, label: &quot;Insert Order&quot;, enabled: 1 class: push_button, focused: 0, label: &quot;Insert Order&quot;, enabled: 0 class: radio_button, focused: 1, value: 1 class: radio_button, focused: 0, value: 1 class: radio_button, focused: 0, value: 0
  • 211. Determine Type of Synchronization (Change in Object Property/State) 2 obj_wait_info (&quot;Bar&quot;,&quot;label&quot;, &quot;Insert Done...&quot;, 20); Object name Object property Synchronize with a progress bar message
  • 212. Determine Type of Synchronization (Change in Object Property/State) 2 obj_wait_info (&quot;Bar&quot;,&quot;label&quot;, &quot;Insert Done...&quot;, 20); value Time Synchronize with a progress bar message
  • 213. Determine Type of Synchronization (Waiting for a Bitmap) 2 obj_wait_bitmap (&quot;Window&quot;, &quot;Img1&quot;, 10, 209, 170, 81, 20 ); Object name Bitmap name Sync with browser loading a bitmap
  • 214. Determine Type of Synchronization (Waiting for a Bitmap) 2 obj_wait_bitmap (&quot;Window&quot;, &quot;Img1&quot;, 10, 209, 170, 81, 20 ); Time x , y Sync with browser loading a bitmap
  • 215. Determine Type of Synchronization (Waiting for a Bitmap) 2 obj_wait_bitmap (&quot;Window&quot;, &quot;Img1&quot;, 10, 209, 170, 81, 20 ); width height Img1.bmp Bitmap File Location: Test_name exp Test_name Sync with browser loading a bitmap
  • 216. How Long Does It Wait? &quot;OK&quot; &quot;Error&quot; TIME PARAMETER Global timeout setting Global timeout interval GLOBAL + Test run 1 TOTAL = Maximum total timeout Synchronization statement timeout parameter Script continues Script continues Test run 2
  • 217. Add Synchronization to Test Script Wait for a Window 3 # Login set_window ( &quot;Login&quot; ,4); edit_set ( &quot;Agent Name:&quot;, &quot;mercury&quot; ); password_edit_set ( &quot;Password:&quot;,&quot;kjzisllz&quot; ); button_press ( &quot;OK&quot; ); # Flight Reservation set_window ( &quot;Flight Reservation&quot; , 25 ); Locate the TSL statement that points to the determined visual cue 1
  • 218. Add Synchronization to Test Script Wait for a Window # Login set_window ( &quot;Login&quot; ,4); edit_set ( &quot;Agent Name:&quot;, &quot;mercury&quot; ); password_edit_set ( &quot;Password:&quot;,&quot;kjzisllz&quot; ); button_press ( &quot;OK&quot; ); # Flight Reservation set_window ( &quot;Flight Reservation&quot; , 25 ); 3 Recorded time parameter reflects delay during script recording session 60 Locate the TSL statement that points to the determined visual cue 1 Modify timeout parameter to allow ample time for window to appear 2
  • 219. Add Synchronization to Test Script Wait for an Object State/Property Value list_select_item ( &quot;Fly From:&quot;,&quot;Denver&quot; ); list_select_item ( &quot;Fly To:&quot;,&quot;San Francisco&quot; ); # Flights Table set_window ( &quot;Flights Table&quot; ,2); list_activate_item ( &quot;Flight&quot;, &quot;2452...&quot; ); # Flight Reservation set_window ( &quot;Flight Reservation&quot; ,3); edit_set ( &quot;Customer Name:&quot;,&quot;Bob Smith&quot; ); button_press ( &quot;Insert Order&quot; ); 3 Locate the line in the script to insert the synchronization point 1
  • 220. Add Synchronization to Test Script Wait for an Object State/Property Value list_select_item ( &quot;Fly From:&quot;,&quot;Denver&quot; ); list_select_item ( &quot;Fly To:&quot;,&quot;San Francisco&quot; ); # Flights Table set_window ( &quot;Flights Table&quot; ,2); list_activate_item ( &quot;Flight&quot;, &quot;2452...&quot; ); # Flight Reservation set_window ( &quot;Flight Reservation&quot; ,3); edit_set ( &quot;Customer Name:&quot;,&quot;Bob Smith&quot; ); button_press ( &quot;Insert Order&quot; ); 3 Locate the line in the script to insert the synchronization point 1 Select Create > Synchronization Point/For Object/Window Property 2
  • 221. Add Synchronization to Test Script Wait for an Object State/Property Value list_select_item ( &quot;Fly From:&quot;,&quot;Denver&quot; ); list_select_item ( &quot;Fly To:&quot;,&quot;San Francisco&quot; ); # Flights Table set_window ( &quot;Flights Table&quot; ,2); list_activate_item ( &quot;Flight&quot;, &quot;2452...&quot; ); # Flight Reservation set_window ( &quot;Flight Reservation&quot; ,3); edit_set ( &quot;Customer Name:&quot;,&quot;Bob Smith&quot; ); button_press ( &quot;Insert Order&quot; ); 3 Using the Hand pointer, click on the object to synchronize 3 Locate the line in the script to insert the synchronization point 1 Select Create > Synchronization Point/For Object/Window Property 2
  • 222. Add Synchronization to Test Script Wait for an Object State/Property Value list_select_item ( &quot;Fly From:&quot;,&quot;Denver&quot; ); list_select_item ( &quot;Fly To:&quot;,&quot;San Francisco&quot; ); # Flights Table set_window ( &quot;Flights Table&quot; ,2); list_activate_item ( &quot;Flight&quot;, &quot;2452...&quot; ); # Flight Reservation set_window ( &quot;Flight Reservation&quot; ,3); edit_set ( &quot;Customer Name:&quot;,&quot;Bob Smith&quot; ); button_press ( &quot;Insert Order&quot; ); 3 &quot;Progress Bar&quot; Select the object attribute that will contain the value of the visual cue 4 Using the Hand pointer, click on the object to synchronize 3 Locate the line in the script to insert the synchronization point 1 Select Create > Synchronization Point/For Object/Window Property 2
  • 223. Add Synchronization to Test Script Wait for an Object State/Property Value list_select_item ( &quot;Fly From:&quot;,&quot;Denver&quot; ); list_select_item ( &quot;Fly To:&quot;,&quot;San Francisco&quot; ); # Flights Table set_window ( &quot;Flights Table&quot; ,2); list_activate_item ( &quot;Flight&quot;, &quot;2452...&quot; ); # Flight Reservation set_window ( &quot;Flight Reservation&quot; ,3); edit_set ( &quot;Customer Name:&quot;,&quot;Bob Smith&quot; ); button_press ( &quot;Insert Order&quot; ); 3 obj_wait_info ( &quot;Progress Bar&quot; , &quot;label&quot; , &quot;Insert Done…”, 10); &quot;Progress Bar&quot; Click the Paste button in Wait for object window 5 Select the object attribute that will contain the value of the visual cue 4 Using the Hand pointer, click on the object to synchronize 3 Locate the line in the script to insert the synchronization point 1 Select Create > Synchronization Point/For Object/Window Property 2
  • 224. Add Synchronization to Test Script Wait for a Bitmap Area 3 # Mercury Homepage set_window ( &quot;Mercury Homepage&quot; , 5 ); edit_set ( &quot;Address&quot;, &quot;http://www.merc-int.com” ); obj_mouse_click ( &quot;mpage&quot;, &quot;Img2&quot; , 471, 328 ); Locate the line in the script to insert the synchronization point 1
  • 225. Add Synchronization to Test Script Wait for a Bitmap Area # Mercury Homepage set_window ( &quot;Mercury Homepage&quot; , 5 ); edit_set ( &quot;Address&quot;, &quot;http://www.merc-int.com” ); obj_mouse_click ( &quot;mpage&quot;, &quot;Img2&quot; , 471, 328 ); 3 Select Create > Synchronization Point > For Screen Area Bitmap 2 Locate the line in the script to insert the synchronization point 1
  • 226. Add Synchronization to Test Script Wait for a Bitmap Area 3 # Mercury Homepage set_window ( &quot;Mercury Homepage&quot; , 5 ); edit_set ( &quot;Address&quot;, &quot;http://www.merc-int.com” ); obj_mouse_click ( &quot;mpage&quot;, &quot;Img2&quot; , 471, 328 ); Click left mouse button and drag pointer to select area; press right button to complete selection 3 Select Create > Synchronization Point > For Screen Area Bitmap 2 Locate the line in the script to insert the synchronization point 1
  • 227. Add Synchronization to Test Script Wait for a Bitmap Area 3 # Mercury Homepage set_window ( &quot;Mercury Homepage&quot; , 5 ); edit_set ( &quot;Address&quot;, &quot;http://www.merc-int.com” ); obj_wait_bitmap ( &quot;mpage&quot;,&quot;Img2&quot; ,6,7,8,101,114); obj_mouse_click ( &quot;mpage&quot;, &quot;Img2&quot; , 471, 328 ); TSL statement appears in script 4 Locate the line in the script to insert the synchronization point 1 Click left mouse button and drag pointer to select area; press right button to complete selection 3 Select Create > Synchronization Point > For Screen Area Bitmap 2
  • 228. Other Object State Synchronization Statements
    • button_wait_info
    • edit_wait_info
    • list_wait_info
    • menu_wait_info
    • obj_wait_info
    • scroll_wait_info
    • spin_wait_info
    • static_wait_info
    • statusbar_wait_info
    • tab_wait_info
  • 229. Play Back Revised Script 4 edit_set (&quot;Date&quot;,&quot;070703&quot;); list_select_item (&quot;Fly From:&quot;, &quot;Los Angeles&quot;); button_press ( &quot;Flights&quot; ); set_window (&quot;Flights Table&quot;, 4); list_activate_item (&quot;Flight&quot;, . . .) edit_set ( &quot;Customer Name:&quot;, &quot;Errol Flynn&quot; ); button_press ( &quot;Insert Order&quot; ); obj_wait_info ( &quot;ProgressBar&quot;,&quot;label&quot;, &quot;Insert Done...&quot; ,10); 07/07/03 Los Angeles Denver Cash edit_set ( &quot;Date&quot;,&quot;070703&quot; ); list_select_item ( &quot;Fly From:&quot;, &quot;Los Angeles&quot; ); list_select_item ( &quot;Fly To:&quot;, &quot;Denver&quot; ); list_select_item ( &quot;Payment:&quot;, &quot;Cash&quot; ); set_window ( &quot;Flights Table&quot; , 4); list_activate_item ( &quot;Flight&quot; , . . .);
  • 230. Play Back Revised Script 4 07/07/03 Los Angeles Denver Cash edit_set (&quot;Date&quot;,&quot;070703&quot;); list_select_item (&quot;Fly From:&quot;, &quot;Los Angeles&quot;); list_select_item (&quot;Payment:&quot;, &quot;Cash&quot;); button_press ( &quot;Flights&quot; ); edit_set ( &quot;Customer Name:&quot; , &quot;Errol Flynn&quot; ); button_press ( &quot;Insert Order&quot; ); set_window (&quot;Flights Table&quot;, 4); list_activate_item (&quot;Flight&quot;, . . .) obj_wait_info ( &quot;ProgressBar&quot;,&quot;label&quot;, &quot;Insert Done...&quot; ,10); 07/07/03 edit_set ( &quot;Date&quot;,&quot;070703&quot; ); list_select_item ( &quot;Fly From:&quot;, &quot;Los Angeles&quot; ); list_select_item ( &quot;Fly To:&quot;, &quot;Denver&quot; ); list_select_item ( &quot;Payment:&quot;, &quot;Cash&quot; ); set_window ( &quot;Flights Table&quot; , 4); list_activate_item ( &quot;Flight&quot; , . . .);
  • 231. Play Back Revised Script 4 edit_set ( &quot;Date&quot;,&quot;070703&quot; ); list_select_item ( &quot;Fly From:&quot;, &quot;Los Angeles&quot; ); list_select_item ( &quot;Fly To:&quot;, &quot;Denver&quot; ); list_select_item ( &quot;Payment:&quot;, &quot;Cash&quot; ); button_press ( &quot;Flights&quot; ); edit_set ( &quot;Customer Name:&quot;, &quot;Errol Flynn&quot; ); button_press ( &quot;Insert Order&quot; ); obj_wait_info( &quot;ProgressBar&quot;,&quot;label&quot;, &quot;Insert Done...&quot; ,10); set_window ( &quot;Flights Table&quot; , 4); list_activate_item ( &quot;Flight&quot; , . . .); . . . Errol Flynn 07/07/03 101
  • 232. Summary
    • The AUT's performance may slow down as the number of users increases
    • Synchronization points allow WinRunner to wait for the AUT, just like a real user
    • Synchronization Points wait for
      • windows or bitmaps to appear
      • objects to change state
    • Maximum wait time for a Synchronization Point is the time parameter + global timeout
  • 233. LAB EXERCISE
  • 234.
    • Create Bitmap Synchronization for Insert Order Image
    • Add Synchronization points to all INSERT,DELETE operations
  • 235. Enhancing Your Test Using TSL Test Script Language
  • 236. Enhancing Your Test Using TSL
    • In this lesson you will learn:
    • How TSL can enhance test scripts:
      • maintainability
      • readability
      • reliability
      • portability
    • Some important TSL functions
    • How to insert TSL statements into your script using the Function Generator
  • 237. What is TSL ?
    • It is a C-like language
      • flow control (for, while, if / else…, switch)
      • case sensitive
      • operators (arithmetic, relational…)
      • input/output
    • It is a Basic-like language
      • constants, variables, arrays
    • It is interpreted for easy debugging
    • It has built-in Testing Functions
      • recorded
      • programmed
  • 238. Variables and Constants
    • Use variables and constants to:
      • remove hard-coded data for maintainability, readability
      • store data (i.e., input/output data, error codes)
      • create data driven tests
    • Variables do not have to be declared
      • they can always contain strings or numbers
    • Variables and constants can be of type public or static
      • public: available to all tests and function libraries
      • static: available to only the script in which it is declared
  • 239. Variables and Constants Variable and Constant Names: - letters, numbers, underscore - first character must be a letter or an underscore - case sensitive # Constant declarations public const GUI_FILE_PATH = “c:estsuifiles; public const AUT_PATH = “c:ppin; public const E_MY_ERROR_CODE = -12345; # Variable declarations static lineCounter ; public flightVersion = “Flight1a.exe”; Test Script 1 Examples GUI_load ( GUI_FILE_PATH & “myFile.gui”); invoke_application ( AUT_PATH & flightVersion , ““, AUT_PATH , SW_SHOW); ... rc = my_function (); if (rc == E_MY_ERROR_CODE ) ... Test Script 2
  • 240. Variables and Constants Strings and Numbers number1 = &quot;4&quot; ; number2 = 3 ; value = number1 * number2; value contains 12 cost = &quot;10 Dollars&quot; ; amount = “The price is “ & cost + 5 ; amount contains “The price is 15” value_a = &quot;3.3&quot; ; value_b = &quot;2,5&quot; ; result_a = value_a * 2 ; result_b = value_b * 4 ; result_a contains 6.6 result_b contains 8 Sample 1 Sample 2 Sample 3 WinRunner can convert strings to numbers and vice versa! If a string is converted to a number, WinRunner cuts off all following non-numeric characters!
  • 241. Variables and Constants Special Characters in Strings
    • The backslash is used to start an escape-sequence, (a special character)
      • Tab
      • Return, Newline
      • ” Quotes
    • To Insert a backslash into a string use a double backslash
      • Backslash
    value = &quot;This is a &quot;String&quot; with very special character&quot; ; pause ( value );
  • 242. Arrays
    • Use arrays when you need to store many data values using one data structure
      • allow for easy access to large sets of data
      • allow for storing sets of data
    • Array size can be dynamically increased
      • test script expandability
    • Each array element can be indexed by a user-defined string (associative arrays)
    • Multi-dimensional arrays are supported
  • 243. Arrays Simple Array fltclass[ 1 ]= &quot;First&quot; ; fltclass[ 2 ]= &quot;Business&quot; ; fltclass[ 3 ]= &quot;Economy&quot; ; # Data Window set_window ( &quot;Data Window&quot; , 1 ); edit_get_text ( &quot;Class Number:&quot; , class ); # Flight Reservation set_window ( &quot;Flight Reservation&quot; , 1 ); button_set ( fltclass[class] , ON ); Sample
  • 244. Arrays Associative Array userdata[ &quot;name&quot; ]= &quot;John Smith&quot; ; userdata[ &quot;address&quot; ]= &quot;1234 Main Street&quot; ; userdata[ &quot;zip&quot; ]= 98711 ; userdata[ &quot;city&quot; ]= &quot;Hometown &quot; ; # Customer Information Window set_window ( ”Customer Information Window&quot; , 1 ); edit_set ( &quot;Name:&quot; , userdata[ &quot;name&quot; ] ); edit_set ( &quot;Address:&quot; , userdata[ &quot;address&quot; ] ); edit_set ( &quot;City:&quot; , userdata[ &quot;zip&quot; ] & &quot;, &quot; & userdata[ &quot;city&quot; ] ); Sample
  • 245. Arrays Multi-dimensional Arrays flightinfo[ 1 , &quot;Date” ] = &quot;07/22/99&quot; ; flightinfo[ 1 , &quot;FlyFrom” ] = &quot;Los Angeles&quot; ; flightinfo[ 1 , &quot;FlyTo” ] = &quot;Denver&quot; ; flightinfo[ 1 , &quot;Flight No” ] = &quot;4300&quot; ; flightinfo[ 2 , &quot;Flight No” ] = &quot;1234&quot; ; flightinfo[ 3 , &quot;Flight No” ] = &quot;9999&quot; ; Example: Multi-dimensional Array Date Fly From Fly To Flight No 1 2 3 07/22/99 09/28/01 12/26/02 Los Angeles Seattle Dallas Detroit Portland Denver 4300 1234 9999 Multi-dimensional Arrays; Data in table format
  • 246. Flow Control
    • Add flow control to increase the test script’s reliability and maintainability
      • make decisions in a test script
      • handle predictable AUT behavior
      • iterate repeated user actions
      • handle multiple window paths in AUT
      • create a data driven test
    • Flow control constructs:
      • conditional
      • looping
      • flow modification
  • 247. Flow Control Conditional Decision Making set_window (“Flight Reservation”); obj_get_info (“Order No:”, “value”, OrderNo); if ( OrderNo == “ ” ) report_msg (“No order number.”); else button_press (“Update Order”); set_window (“Flight Reservation”); obj_get_info (“Order No:”, “value”, OrderNo); if ( OrderNo == “ ” ) { report_msg (“No order number.”); } else { button_press (“Update Order”); } win_get_text(”Flight Info”, version, 42, 68, 159, 89); if ( version != “Version 1.0” ) { report_msg (“Wrong Version!”); texit; } Example 2 Best practice: always set curly brackets Example 1
  • 248. Flow Control switch Statement set_window (&quot;Fax Order&quot;); edit_get_text (&quot;Class:&quot;, class); switch (class) { case &quot;Economy&quot;: result = PASS; message=&quot;Correct class: Economy&quot;; break; case &quot;Business&quot;: result = FAIL; message=&quot;Wrong class: Business&quot;; break; case &quot;First&quot;: result = FAIL; message=&quot;Wrong class: First&quot;; break; } tl_step (“Class of Service”, result, message); Example
  • 249. Flow Control for Loop # Looping for stress testing for (i=0; i<1000; i++) { set_window (“Flight Reservation”); menu_select_item (&quot;File;Fax Order...&quot;); set_window (&quot;Fax Order&quot;); edit_set (&quot;Fax Number:&quot;, “4085551212”); button_press (”Send&quot;); set_window (“Flight Reservation”); obj_wait_info (“StatusBar”, “label”, “Fax Sent”, 50); } Example
  • 250. Flow Control while Loop file= &quot;c:atalight_orders.txt&quot;; file_open( file, FO_MODE_READ ); while ( file_getline( file, line ) == E_OK ) { ord_num= substr( line, 0, 5 ); open_order( ord_num ); report_msg( &quot;Opened Order &quot; & ord_num ); } file_close( file ); The statements in this while loop will not be executed if the condition is not TRUE (if the file cannot be opened) Example
  • 251. Flow Control do while Loop # Flight Reservation set_window ( &quot;Flight Reservation&quot;, 2 ); edit_set ( &quot;Name:&quot;, &quot;&quot; ); new_len=0; do { old_len= new_len; edit_type( &quot;Name:&quot;, &quot;123&quot; ); edit_get_info( &quot;Name:&quot;, &quot;value&quot;, value ); new_len= length( value ); } while( old_len < new_len ); report_msg( &quot;Max Name length ” & new_len & &quot; characters&quot; ); The statements in this while loop are executed at least once. Example
  • 252. Operators
    • Use operators to create expressions by combining
    • variables and constants
    • Arithmetic ( + - * / % ++ -- )
    • Assignment ( = += -= *= /= %= ^= )
    • Concatenation ( & )
    • Conditional ( ? )
    • Logical ( && || ! )
    • Relational ( > >= < <= == != )
  • 253. Operators Arithmetic/Relational edit_get_text (&quot;Tickets&quot;, tickets); edit_get_text (&quot;Price&quot;, price); edit_get_text (&quot;Total&quot;, total); if ( tickets * price == total ) tl_step (“Total”, PASS, “Correct Total”); else { tl_step (“Total”, FAIL, &quot;Wrong Total&quot;); report_msg(“Expected Value: ” & tickets * price); report_msg(“Actual Value: ” & total ); } Best Practice: For complicated calculations, check values in the AUT against pre-calculated values in a data table or data file Example
  • 254. Operators Logical Operators # Value is greater than 50 AND less than 100 if ( value > 50 && value <100 ) tl_step (“Value tested”, PASS, “Correct Value”); Logical AND # Value equals Saturday OR value equals Sunday if ( value== “Saturday” || value== “Sunday” ) tl_step (“Value tested”, PASS, “ it’s Weekend !”); Logical OR # Value is equal to or greater than 1 AND less than or equal to 10 # AND value IS NOT 5 if ( value >=1 && value <=10 && value != 5 ) tl_step (“Value tested ”, PASS, “is between 1-10 and not 5”); Combination
  • 255. TSL Testing Functions
    • TSL contains many non-recorded testing functions to enhance your tests
      • arithmetic, string
      • Data Table (discussed in a later lesson)
      • Test Report, file, query functions
      • synchronization
      • system
    • Finding out about functions
      • Function Generator
      • on-line help
      • TSL Reference manual
      • WinRunner Books Online
  • 256. TSL Testing Functions
    • Arithmetic
      • exp
      • int
    • Input/Output
      • tl_step
      • file_getline
      • file_printf
    • Query GUI Objects
      • edit_get_text
      • obj_get_info
      • win_exists
    • String/File
      • substr
      • file_compare
    • Synchronization
      • list_wait_info
      • obj_wait_info
    • System
      • invoke_application
      • dos_system
      • get_time
    Examples
  • 257. Important TSL Functions Invoking an Application
    • Description: Invokes a Windows application from within a test script
    • Format: invoke_application (file, option, working_dir, show);
    app_path= “c:ercuryinrunneramples”; invoke_application (app_path & “light1a.exe”,“”, app_path, SW_SHOW); Example
  • 258. Important TSL Functions Checking for a Window
    • Description: This statement can be used to verify if an error message appears, the application is started, or a specific window appears on the screen.
    • Format: win_exists( window, [time] );
    If ( win_exists ( “Flight Message” ) == E_OK ) { set_window( “Flight Message”, 2 ); button_press( “OK” ); } Example
  • 259. Important TSL String Functions Splitting a String
    • Description: This statement can be used to split a long string into smaller parts, at every appearance of a given Separator.
    • Format: split(String, Array, Field Separator);
    set_window(&quot;Flights Table&quot;, 1); list_get_item(&quot;Flight&quot;,num, flight); split ( flight, values, &quot; &quot;); if( values[1] == flight_num ) { Example
  • 260. Important TSL Functions Accessing DOS
    • Description: Executes a DOS command from within a test (equivalent to executing a command from a DOS window)
    • Format: dos_system (expression);
    dos_system ( &quot;del c:emo.tmp” ); Example
  • 261. Important TSL Functions Input/Output
    • Read input from the WinRunner Data Table
      • discussed in a later lesson
    • Send output from test:
      • to the report
      • to TestDirector
  • 262.
    • Description: Use tl_step function to report status of a checkpoint
      • divides test into steps & sends a message on success / failure
      • affects test status (pass / fail)
      • makes analysis of test script execution easier
    • Format: tl_step (step_name, status, description);
    Output to Test Report & TestDirector win_get_text (&quot;File Name&quot;, text, 247, 309, 427, 329); if (text == &quot;letter.doc&quot;) tl_step (“Verify Text”, PASS , “Correct text”); else tl_step (“Verify Text”, FAIL , “Wrong text: ” & text ); Example
  • 263. Output to Report report_msg Statement
    • Description: - Send information about the test execution to the Test Report - Does not affect test status.
    • Format: report_msg (string);
    edit_get_text (&quot;File Name&quot;, val ); if (val != &quot;letter.doc&quot;) { report_msg (&quot;Error: Illegal file name: ” & val & “ Test Aborted&quot;); } Example
  • 264.
    • Functions arranged in categories
    Accessing Functions The Function Generator
    • Expand form to fill in argument values
    • Paste into script (or execute)
    • Point and click programming
  • 265. Accessing Functions The Editor # Automobile Purchase Form set_window ( &quot;Automobile Purchase Form&quot; , 10); edit_set ( &quot;Customer Name&quot; , &quot;Thomas Paine&quot; ); edit_ edit_set
    • When you type an underscore, a list with functions will appear
    • Type ESC to hide the function list
    • Continue typing to pre-select other functions
    • TAB, ENTER or SPACE selects the actual function
  • 266. Accessing Functions The Editor # Automobile Purchase Form set_window ( &quot;Automobile Purchase Form&quot; , 10); edit_set ( &quot;Customer Name&quot; , &quot;Thomas Paine&quot; ); edit_set edit_set ( edit_set ( ”Password”, “Mercury”
    • When you type an open bracket a ToolTip with the parameters will appear
    edit_set (Edit Object, New String) edit_set ( ”Password”, “Mercury” );
  • 267. Using Return Codes
    • Each TSL Function has a return code
      • numeric
      • general TSL error codes (E_OK, E_NOT_FOUND)
    • Enhance the readability of your test scripts
      • if (win_exists (&quot;Flight Reservation Message&quot;) == E_OK ) {
      • set_window (&quot;Flight Reservation Message&quot;);
      • button_press (&quot;No&quot;);
      • }
      • rc = set_window (“Flight Reservation”, 10);
      • if ( rc != E_OK) {
      • report_msg (“Flight application did not invoke properly.”);
      • texit (-1); # Aborting test
      • }
    Example 2 Example 1
  • 268. Debugging Tests
    • Step, Step Into
    • Breakpoint
    • Watch Variables
    • pause Statement
  • 269. Debugging Tests pause Statement
    • Halts execution of test script and pops up a message box
    • Ensures that variables and arrays contain the correct data
    Capital = &quot;Sacramento&quot;; pause (&quot;The capital of California is &quot; & Capital);
  • 270. Comments
    • WinRunner ignores anything after a “#” as a comment
    • Thoroughly comment test scripts for readability and maintainability
    • Helps other test developers analyze and edit test scripts
    ################################################################## # Test Name: Verify Login # # Test Developer: John Doe # # Purpose: This test verifies that the login procedure… # # Date: 12.12.97 # # Date of Last Revision: 2.14.98 # ################################################################## # Performing a login to AUT set_window (“Login”); edit_set (“Login Name”, name); # name stores the actual login name Example You can insert comments either during recording or after recording
  • 271. Creating a Startup Script
    • A startup script can contain anything you want executed each time you start WinRunner
      • When working within a team you can use the same startup script to ensure everyone’s environment is similar
      • Set the location of your Startup script in WinRunner’s General Options
    • Use a startup script to:
      • Load your GUI map
      • Declare constants and variables
      • Load your Function Libraries
      • Customize your Function Generator
      • Configure WinRunner’s view of objects
  • 272. Creating a Startup Script ############################################ # TestSuite Training Init Test # ############################################ # Loading the prepared GUI file GUI_load ( getvar ( &quot;testname&quot; )& &quot;light60.gui&quot; ); # Configure the MS Mask object to map to edit objec # Data of Flight recording depends on this set_class_map ( &quot;MSMaskWndClass&quot; , &quot;edit&quot; ); set_record_attr ( &quot;MSMaskWndClass&quot; , &quot;class attached_t set_record_method ( &quot;MSMaskWndClass&quot; , RM_RECORD); # Configure the status bar in the GUI Map set_class_map ( &quot;AfxWnd40&quot; , &quot;object&quot; ); set_record_attr ( &quot;AfxWnd40&quot; , &quot;class regexp_MSW_class S:TestProjectInitScript WinRunner - [InitScript] Create a startup script in WinRunner. 1 Open the General Options window and click the Environment tab. 2 Enter the path where you saved your startup script in the Startup test box. 3
  • 273. Summary
    • Enhance your script using TSL
      • add logic (flow control, variables, operators)
      • insert testing functions using the Function Generator
    • Add comment to your script for clarity
    • Use return values to check successful execution
    • Report checkpoint status information
    • Use debugging tools to check your test
  • 274. LAB EXERCISE
  • 275.
    • Write a Script to get the user input through default dialog box.
    • Write a function to open Flight Reservation Sample Application.
    • Write a startup script for Loading GUI and invoking Application.