Winrunner Training Objective of the Course <ul><li>Understand the benefits of automated testing </li></ul><ul><li>To get a...
Benefits of Automated Testing WinRunner Testing Process WinRunner Recording Mode Working with other Test Suite Tools
Manual Vs. Automated Testing <ul><li>Manual Testing:  </li></ul><ul><li>Is time-consuming and tedious </li></ul><ul><li>Re...
Benefits of Automated Testing Fast:   Run tests significantly faster than human users Reliable:   Tests perform precisely ...
WinRunner Testing Process <ul><li>1 Create the GUI Map </li></ul><ul><ul><li>WinRunner must learn to recognize the objects...
WinRunner Testing Process <ul><li>4 Run Tests </li></ul><ul><ul><li>Run tests in Verify mode to test your application </li...
Recording Mode <ul><li>Context Sensitivity   </li></ul><ul><li>Context Sensitivity  records operations in terms of GUI obj...
Choosing a Recording Mode <ul><li>Choose Context Sensitive if...  </li></ul><ul><li>The application contains GUI objects <...
<ul><li>Starting WinRunner </li></ul><ul><ul><li>To start WinRunner, click  Start > Programs > WinRunner > WinRunner </li>...
<ul><li>Creating a New test </li></ul><ul><ul><li>Click on New Test </li></ul></ul>Recording User Actions
WinRunner Main Window
WinRunner Standard Toolbar
Recording a Test <ul><li>To Record a Test in WinRunner, Select the Record Button from the Standard Toolbar </li></ul>
Recording a Test <ul><li>Open the Application and Enter the Data </li></ul>Automatic Script Generation Enter Application D...
Benefits of Automated Testing WinRunner Testing Process WinRunner Recording Mode Working with other Test Suite Tools
Working with Other Test Suite Tools WinRunner works with other Test Suite tools to provide an integrated solution for all ...
Summary <ul><li>Advantages of Automated Testing over Manual Testing  (Fast, Reliable, Repeatable, Programmable, Comprehens...
LAB EXERCISE
<ul><li>Record Login Process  from Flight Reservation Sample  Application  in Context Sensitivity Mode </li></ul><ul><li>R...
Day 2 <ul><li>Topic </li></ul><ul><li>Setting up GUI Map </li></ul><ul><li>Managing GUI Map </li></ul><ul><li>Using the Ra...
How Does WinRunner  Create the Script?
How Does WinRunner Create the Script? John set_window(&quot;Login&quot;, 10); edit_set (&quot;Name&quot;, ”John&quot;); Re...
How Does WinRunner Run the Script? set_window(&quot;Login&quot;, 10); edit_set (&quot;Name&quot;, ”John&quot;); John Playb...
Main Issues in Script Creation <ul><li>Unique Identification of objects </li></ul><ul><ul><li>WinRunner must uniquely iden...
How Does WinRunner Identify an Object? John ******* WinRunner uses an object’s physical attributes to identify the object ...
How Does WinRunner  Uniquely   Identify an Object? John ******* WR uses the minimum number of  static  attributes to achie...
How Does WinRunner Assign  Object Names? John ******* WinRunner assigns a short name to each object called the  logical na...
Into Which Field Will WinRunner  Play Back? set_window(&quot;Login&quot;, 10); edit_set (&quot;Name:&quot;, &quot;John&quo...
Scope of Identification edit_set (&quot;Name:&quot;, &quot;John&quot;); John WinRunner identifies an object within the sco...
WinRunner Tracks AUT’s Windows and Objects With the GUI Map File <ul><li>The GUI Map file contains the:  </li></ul><ul><li...
GUI Map Editor <ul><li>Visual tree displays windows and objects contained in the GUI Map File </li></ul><ul><li>First leve...
The GUI Map <ul><li>Allows separation of physical attributes from test scripts </li></ul><ul><li>Enables WinRunner to uniq...
GUI Map Translates Logical Names  Into Physical Descriptions  Options Class: Window Label: Window Dealer Name Class: Edit ...
Recording Example Application GUI Map Logical Physical { class: window, MSW_id: 3277 label:  &quot;Save As&quot; } { class...
Playback Example <ul><ul><li>Save As </li></ul></ul>Application GUI Map Logical Physical { class: window, MSW_id: 3277 lab...
Summary <ul><li>WinRunner uniquely identifies every object in the AUT by its physical description </li></ul><ul><li>Each o...
Techniques For Managing GUI Map Files Technique 1 One GUI Map file per test Technique 2 One GUI Map file for many tests
Object and Window Properties  During Recording Name: Description: Date class: edit attached_text: &quot;Date&quot; set_win...
What Happens to These Properties? Use the GUI Map Editor to save the contents of the Temporary GUI Map file to a permanent...
Creating a Permanent GUI Map File  Car_App.gui L1 Car_App.gui Insert Test1 Test2 Testing  Project Tests GUI Technique 1
Adding New Windows and Objects to a GUI Map File Invoke the GUI Map Editor 1 Technique 1
Adding New Windows and Objects to a GUI Map File Technique 1 Invoke the GUI Map Editor 1 Press the  Expand  Button to disp...
Adding New Windows and Objects to a GUI Map File Technique 1 Invoke the GUI Map Editor 1 Move contents of Temp to Permanen...
Adding New Windows and Objects to a GUI Map File Technique 1 Save changes to permanent GUI Map file 4 Invoke the GUI Map E...
Save Project GUI Map Files Together  Insert Test1 Test2 Testing  Project Tests Insert.gui L1 Insert.gui GUI Test1.gui Test...
Techniques for Managing GUI Map Files Technique 1 One GUI Map file per test Technique 2 One GUI Map file for many tests
Creating a Permanent GUI Map File Technique 2 Invoke the GUI Map Editor 1
Creating a Permanent GUI Map File The cursor changes to a pointing hand Technique 2 Invoke the GUI Map Editor 1 Click the ...
Creating a Permanent GUI Map File The cursor changes to a pointing hand Technique 2 Invoke the GUI Map Editor 1 Click the ...
Creating a Permanent GUI Map File The cursor changes to a pointing hand WinRunner learns all objects in window Technique 2...
Creating a Permanent GUI Map File The cursor changes to a pointing hand WinRunner learns all objects in window Technique 2...
Modify Names for Script Readability These names are unreadable. To what objects do they refer ? Technique 2
Modify Names for Script Readability Technique 2 Highlight the object whose name you  want to change 1
Modify Names for Script Readability Technique 2 Highlight the object whose name you  want to change 1 Click the Modify  Bu...
Modify Names for Script Readability Technique 2 Highlight the object whose name you want to change 1 Change the Logical Na...
Modify Names for Script Readability &quot;Name:”  appears in your test script during recording instead of  &quot;ThunderRT...
Creating a Permanent GUI Map File  Car_App.gui L1 Car_App.gui Insert Test1 Test2 Testing  Project Tests GUI Technique 2
Which Technique Should You Use? Technique 1 Advantages 1.  Each test has GUI Map file    independence 2.  There is no need...
Importance of the GUI Map File ? set_window(&quot;Automobile Purchase Form&quot;, 10); edit_set (&quot;Date&quot;, &quot;1...
Load GUI Map File from Script GUI_load(&quot;N:2K_ProjUInsert.gui&quot;); set_window(&quot;Automobile Purchase Form&quot;,...
Unload GUI Map File from Script GUI_load(&quot;N:2K_ProjUInsert.gui&quot;); Insert.gui set_window(&quot;Automobile Purchas...
Fixing the GUI Map File set_window(&quot;Automobile Purchase Form&quot;, 10); edit_set (&quot;Date&quot;, &quot;12/12/03&q...
Fixing the GUI Map File 2 set_window(&quot;Automobile Purchase Form&quot;, 10); edit_set (&quot;Date&quot;, &quot;12/12/03...
Use the GUI Map Editor to Fix File *L1 Insert.gui L1 Insert.gui Active GUI file: N:2K_ProjectUIinsert.gui Invoke the GUI M...
Fixing the GUI Map File 12/12 /03 set_window(&quot;Automobile Purchase Form&quot;, 10); edit_set (&quot;Date&quot;, &quot;...
Custom User Toolbar <ul><li>The Custom User Toolbar feature allows you to customize WinRunner’s UI to suit your testing ne...
Add GUI Map Editor to the Custom User Toolbar An icon for each command selected is added to the User Toolbar Select Settin...
Summary <ul><li>Two methods to manage GUI Map files </li></ul><ul><ul><li>1 GUI Map per test </li></ul></ul><ul><ul><ul><l...
LAB EXERCISE
<ul><li>Use GUI Spy to learn the objects </li></ul><ul><li>Record Flight Application Sample and Save the temporary GUI Map...
Day 3 <ul><li>Topic </li></ul><ul><li>Introduction to Verification </li></ul><ul><li>GUI Checkpoints </li></ul><ul><li>Dat...
Verification GUI Checkpoints Database Checkpoints Bitmap Checkpoints Text  Checkpoints
Verifying the AUT - Manual Testing PASS ? Step Step Description Expected Result 1 Select File > New SOFTWARE REQUIREMENT S...
Verifying the AUT - Manual Testing Step Step Description Expected Result William Frawley PASS ? 2 Enter your name The  Ter...
Verifying the AUT - Manual Testing Step Step Description Expected Result 2 Enter your name The  Terms  button is enabled 1...
Verifying the AUT - Automated Testing     William Frawley ? set_window (&quot;Automobile Purchase Form&quot;, 8); menu...
What Is WinRunner Verification? Definition: Verification is the process by which WinRunner reports whether expected result...
How WinRunner Verifies WinRunner compares the actual result to the stored, expected result 3 WinRunner captures an actual ...
How Does a Checkpoint Work? 1 2 3 4 = X ? WinRunner WinRunner WinRunner WinRunner Pass Fail Test Report Expected AUT Actua...
Process to Create Verification Run the recorded test script to verify correct execution 3 Test the checkpoint to ensure th...
Playback  -  Run Modes <ul><li>DEBUG To check for errors in the script (Results folder:  debug ) </li></ul><ul><li>VERIFY ...
GUI Object Verification <ul><li>Is the window the correct size? </li></ul><ul><li>Is the OK button enabled? </li></ul><ul>...
Database Verification <ul><li>Check the contents and dimensions of a database </li></ul><ul><li>Directly verify database-r...
Bitmap Image Verification <ul><li>Check non-GUI object areas of  the application  by capturing a  bitmap  </li></ul><ul><l...
Text Verification <ul><li>Read and verify text from bitmap areas or non-GUI object based interfaces (e.g., ASCII) </li></ul>
Summary <ul><li>Verification allows WinRunner to check the AUT's behavior </li></ul><ul><li>Types of verification checks <...
Verification GUI Checkpoints Database Checkpoints Bitmap Checkpoints Text  Checkpoints
How Does GUI Checkpoints Work ? 1 2 3 4 = X ? WinRunner WinRunner WinRunner WinRunner Pass Fail Test Report Expected Actua...
Process for GUI checkpoints Test the Checkpoint to ensure that it works for ‘Pass’ & ‘Fail’ conditions 3 Create GUI checkp...
Process for GUI checkpoints 1 Determine the visual cue(s)
Which visual cues demonstrate that the AUT meets requirements <ul><li>Flight Reservation Order information form </li></ul>...
Determine which visual cues to verify ? <ul><li>Edit Field </li></ul><ul><ul><li>Compare </li></ul></ul><ul><ul><li>Enable...
Checkpoint differs depending on the object to be verified Win_check_info Window Obj_check_info Generic Object button_check...
Process for GUI checkpoints Create GUI checkpoint 2 1 Determine the visual cue(s)
Create GUI Checkpoints <ul><li>Select Checkpoint to fit the verification </li></ul>State, Label Enabled, Focus Multiple pr...
Check One property of one Object <ul><li>Select GUI Checkpoint for single property </li></ul>set_window(“Login&quot;, 2); ...
Check One property of one Object <ul><li>Select GUI Checkpoint for single property </li></ul>button_check_info (“OK”,”enab...
Check Multiple properties of one Object <ul><li>Select GUI Checkpoint for Object/Window </li></ul>set_window(“Login&quot;,...
Check Multiple properties of one Object <ul><li>Select GUI Checkpoint for Object/Window </li></ul>obj_check_gui ( &quot;OK...
Check Multiple properties of one Object <ul><li>Select GUI Checkpoint for Object/Window </li></ul>obj_check_gui ( &quot;OK...
Check Multiple properties of multiple Objects <ul><li>Select GUI Checkpoint for Multiple Objects </li></ul>set_window(“Log...
Check Multiple properties of multiple Objects <ul><li>Select GUI Checkpoint for Multiple Objects </li></ul><ul><li>Click A...
Check Multiple properties of multiple Objects <ul><li>Select GUI Checkpoint for Multiple Objects </li></ul><ul><li>Click A...
Check Multiple properties of multiple Objects <ul><li>Select GUI Checkpoint for Multiple Objects </li></ul>win_check_gui (...
Process for GUI checkpoints Test the Checkpoint to ensure that it works for ‘Pass’ & ‘Fail’ conditions 3 Create GUI checkp...
Test the checkpoint <ul><li>Checkpoint should work for both ‘Pass’ and ‘Fail’ condition </li></ul><ul><li>Set the object t...
Process for GUI checkpoints Test the Checkpoint to ensure that it works for ‘Pass’ & ‘Fail’ conditions 3 Create GUI checkp...
Verify correct Script Execution <ul><li>After successfully testing the Checkpoints for ‘Pass’ and ‘Fail’ conditions </li><...
Test directory after GUI Checkpoint Testing  Project Tests chklist List1.ckl exp Test2 gui1.chk Test1 Test2
Summary <ul><li>GUI Checkpoint can verify </li></ul><ul><ul><li>One property of one object </li></ul></ul><ul><ul><li>Mult...
Verification GUI Checkpoints Database Checkpoints Bitmap Checkpoints Text  Checkpoints
Database Checkpoint Definition: A test script checkpoint which verifies the schema table contains the expected data
Flight Database Schema Flight_Number (FK) Order_Number (PK) Orders Flight_Number (PK) Flight A Foreign Key value in a tabl...
Queries Extract Data <ul><li>Select Order_Number from Orders  Where Flight_Number = ‘19075’ </li></ul>11 Order_Number
Why use Database Checkpoints ? <ul><li>Does the AUT insert , update and delete records correctly </li></ul><ul><li>Do the ...
What can you check in a Database ? <ul><li>No of Columns </li></ul><ul><li>No of Rows </li></ul><ul><li>Data content of th...
How does WinRunner Query the Data ? <ul><li>WinRunner integrates with MS Query or a Data Junction </li></ul><ul><li>MS Que...
How Does Database Checkpoint Work ? 1 2 3 4 = X ? WinRunner WinRunner WinRunner WinRunner Pass Fail Test Report Expected A...
Process for Database Checkpoints Test the condition to ensure that it works for Pass and Fail conditions 3 Use Database Ch...
Process for Database Checkpoints 1 Record User actions to create database transaction
Record user actions to create a Database transaction edit_set  ( &quot;Name:&quot; ,  &quot;Preeti&quot; ); button_press  ...
Process for Database Checkpoints Use Database Checkpoint wizard to implement the database checkpoint 2 1 Record User actio...
Use Database Checkpoint Wizard <ul><li>Select Database Checkpoint for default check </li></ul>set_window(“Login&quot;, 2);...
Use Database Checkpoint Wizard <ul><li>Select Database Checkpoint for default check </li></ul><ul><li>Create a Query to ex...
Use Database Checkpoint Wizard <ul><li>Select Database Checkpoint for default check </li></ul>db_check ( &quot;list1.cdl&q...
Process for Database  checkpoints Test the condition to ensure that it works for Pass and Fail conditions 3 Use Database C...
Test the checkpoint <ul><li>Checkpoint should work for both ‘Pass’ and ‘Fail’ condition </li></ul><ul><li>Set the database...
Process for Database checkpoints Test the Checkpoint to ensure that it works for ‘Pass’ & ‘Fail’ conditions 3 Use Database...
Verify correct Script Execution <ul><li>After successfully testing the Checkpoints for ‘Pass’ and ‘Fail’ conditions </li><...
Test directory after Database Checkpoint Testing  Project Tests chklist list1.cdl msqr1.sql exp Test2 dbvf1 Test1 Test2
Summary <ul><li>Use Database Checkpoints to verify data in the Database </li></ul><ul><li>Use MS Query to extract data </l...
Verification GUI Checkpoints Database Checkpoints Bitmap Checkpoints Text  Checkpoints
Bitmap Checkpoint Definition: <ul><li>Bitmap checkpoint are non–context sensitive and are dependent upon the screen resolu...
Is Bitmap Checkpoint necessary? Bitmap Checkpoint GUI Checkpoint <ul><li>Used to verify non-GUI Object areas e.g. Drawing ...
How Does Bitmap Checkpoint Work ? 1 2 3 4 = X ? WinRunner WinRunner WinRunner WinRunner Pass Fail Test Report Expected Act...
Process for Bitmap Checkpoints Test the condition to ensure that it works for Pass and Fail conditions 3 Create a Bitmap C...
Process for Bitmap Checkpoints Create a Bitmap Checkpoint in the recorded Test Script 2 1 Is Bitmap verification necessary...
Create a Bitmap Checkpoint <ul><li>Create a Bitmap Checkpoint for Object/Window or a Screen Area </li></ul>set_window(“Log...
Create a Bitmap Checkpoint <ul><li>Create a Bitmap Checkpoint for Object/Window or a Screen Area </li></ul><ul><li>Point t...
Create a Bitmap Checkpoint <ul><li>Create a Bitmap Checkpoint for Object/Window or a Screen Area </li></ul>obj_check_bitma...
Process for Bitmap Checkpoints Test the condition to ensure that it works for Pass and Fail conditions 3 Create a Bitmap C...
Test the checkpoint <ul><li>Checkpoint should work for both ‘Pass’ and ‘Fail’ condition </li></ul><ul><li>Set the object t...
Verify correct Script Execution <ul><li>After successfully testing the Checkpoints for ‘Pass’ and ‘Fail’ conditions </li><...
Process for Bitmap  Checkpoints Test the Checkpoint to ensure that it works for ‘Pass’ & ‘Fail’ conditions 3 Create a Bitm...
Differences are reported and the difference Bitmap is found <ul><li>Expected Result </li></ul>Actual Result Difference Bit...
Summary <ul><li>Use Bitmap checkpoint for non GUI objects </li></ul><ul><li>You can define specific area of bitmap to veri...
Verification GUI Checkpoints Database Checkpoints Bitmap Checkpoints Text  Checkpoints
Why use a Text Checkpoint ? <ul><li>Verify range of values </li></ul><ul><li>Calculate dynamic values </li></ul><ul><li>Br...
Process for Text Checkpoints Insert code to compare the actual and expected value 3 Insert a function to read the actual t...
Process for Text Checkpoints 1 Define a variable in the script and assign the expected value
Define a variable in the script and assign the expected value <ul><li>for e.g.  tickets_sold =“Total tickets sold is 26” <...
Process for Text Checkpoints Insert a function to read the actual text from the AUT during playback 2 1 Define a variable ...
Insert a function to read the actual text from the AUT during playback <ul><li>There are three ways to insert functions de...
Process for Text Checkpoints Insert code to compare the actual and expected value 3 Insert a function to read the actual t...
Insert code to compare the actual and expected value <ul><li>set_window(&quot;Graph&quot;, 1); obj_get_text(&quot;GS_Drawi...
Process for Text Checkpoints Insert code to compare the actual and expected value 3 Insert a function to read the actual t...
LAB EXERCISE
<ul><li>In the “Burger Application” check whether Medium Burger,Medium French French Fries and Apple juice are selected by...
Data Driven Tests
Data-Driven Tests <ul><li>In this lesson you will learn: </li></ul><ul><li>What is a data-driven test </li></ul><ul><li>Ho...
What is a Data-Driven Test? <ul><li>A test contains: </li></ul><ul><li>Actions: list_select_item(&quot;Fly From:&quot;,&qu...
What is a Data-Driven Test? <ul><li>Data-driven test: </li></ul><ul><li>Test is modified to read data from the Data Table ...
What Is the Data Table? The Data Table is a spreadsheet file in WinRunner that stores the input values you will use to dat...
Advantages of a Data-Driven Test <ul><li>Run the same test with different data </li></ul><ul><li>Expandable </li></ul><ul>...
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 d...
1. Create a Test Create Test with Data invoke_application(“flight1a.exe&quot;,&quot;&quot;,&quot;C:amp;quot;,SW_SHOW); set...
1. Create a Test Verify that Script Is Ready to Data Drive  invoke_application(“flight1a.exe&quot;,&quot;&quot;,&quot;C:am...
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 fr...
The DataDriver Wizard will convert your baseline script table =  &quot;default.xls&quot; ;  rc =  ddt_open (table, DDT_MOD...
Open the Data Table and check that it was successfully opened   1 table =  &quot;default.xls&quot; ;  rc =  ddt_open (tabl...
table =  &quot;default.xls&quot; ;  rc =  ddt_open (table, DDT_MODE_READ); if  (rc!= E_OK && rc != E_FILE_OPEN) pause ( &q...
2. Modify Test to Read from Data Table What Does the DataDriver Do? table =  &quot;default.xls&quot; ;  rc =  ddt_open (ta...
2. Modify Test to Read from Data Table Running the DataDriver Wizard invoke_application(“flight1a.exe&quot;,&quot;&quot;,&...
2. Modify Test to Read from Data Table Running the DataDriver Wizard Final Result table  = &quot; default.xls &quot;;   rc...
2. Modify Test to Read from Data Table Running the DataDriver Wizard Where does the Data Table reside? <test   name> defau...
2. Modify Test to Read from Data Table Running the DataDriver Wizard How do you populate the Data Table? <ul><li>If you wa...
3. Move Data to Data Table Importing Data From Database to Data Table Database
3. Move Data to Data Table Importing Data From Database to Data Table Database
2. Modify Test to Read from Data Table Running the DataDriver Wizard edit_set (&quot;Agent Name:&quot;, “Catherine”); ? Fi...
2. Modify Test to Read from Data Table Running the DataDriver Wizard
Data Driving Tests Create a test 1 2 3 Move data to  Data Table Modify test to read from Data Table
3. Move Data to Data Table How Is Data Moved to Data Table? <ul><li>Import, using DataDriver Wizard  (covered in previous ...
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 s...
3. Move Data to Data Table Add Data Dynamically During Run Create Invoice Test 1 mer InvoiceNum 3421 yelet phine Data Tabl...
3. Move Data to Data Table Add Data Dynamically During Run Add column to Data Table for data to be  added 1
3. Move Data to Data Table Add Data Dynamically During Run table = &quot;default.xls&quot;;  rc = ddt_open(table, DDT_MODE...
Summary <ul><li>Create a “template” test with single set of data </li></ul><ul><li>Modify test to read data from table </l...
Exercise
<ul><li>Create a Data Driven test on Login and Password and Error Messages that it can generate. </li></ul><ul><li>Create ...
Lesson Objectives <ul><li>In this section, we will learn </li></ul><ul><li>the importance of synchronization for successfu...
How Do Client-Server Applications Behave? Single User Database server Server response time:
How Do Client-Server Applications Behave?  Several Users Database server Server response time:
How Do Client-Server Applications Behave?  Many Users Database server Server response time:
How Do Client-Server Applications Behave?  Example Response Times RESPONSE TIME Several users 0.61 Many users 1.00 Single ...
Complete the Business Process Manually Database 07/07/01 Los Angeles Denver Cash Enter 07/07/01 on Date field Select LA fr...
Complete the Business Process Manually Database Enter 07/07/01 on Date field Select LA from Fly From field Select Denver f...
Complete the Business Process Manually Database 07/07/01 Los Angeles Denver Cash Errol Flynn Enter Customer Name Insert Or...
Manual Steps Recorded  in the Test Script edit_set   (&quot;Date&quot;,&quot;070701&quot;); list_select_item  ( &quot;Fly ...
Why Not Insert a Wait Statement? button_press  ( &quot;Insert Order&quot; ); win_close  ( &quot;Flight Reservation&quot; )...
Why Not Insert a Wait Statement? AUT 11.3 seconds RUN #1 Wait (10); button_press  ( &quot;Insert Order&quot; ); win_close ...
Why Not Insert a Wait Statement? AUT 5.5 seconds RUN #2 Wait (15); 15 seconds button_press  ( &quot;Insert Order&quot; ); ...
What Is a Synchronization Point? A synchronization point is a line in the test script that instructs WinRunner to wait for...
ADD SYNCHRONIZATION POINTS Introduction to Synchronization Add Synchronization Points Record user actions in script 1 Sync...
Process to Add Synchronization Points Add Synchronization Points Establish visual cues to synchronize 1 Determine type of ...
Establish Visual Cue to Synchronize Examples 1 Wait for a bitmap to refresh BITMAP Wait for a window WINDOW Wait for an ob...
Methods of Synchronization  obj_wait_info (&quot;Bar&quot;,&quot;label&quot;, &quot;Insert Done...&quot;, 20); Wait for an...
Determine Type of Synchronization (Waiting for a Window) 2 Window name Time set_window (&quot;Flight Reservation&quot;, 20...
Properties of Standard GUI Objects (Examples) Boolean Values 0 = False 1 = True State 3 State 2 State 1 class: push_button...
Properties of Standard GUI Objects (Examples) Boolean Values 0 = False 1 = True State 3 State 2 State 1 class: list, focus...
Properties of Standard GUI Objects (Examples) Boolean Values 0 = False 1 = True State 3 State 2 State 1 class: list, focus...
Determine Type of Synchronization (Change in Object Property/State) 2 obj_wait_info (&quot;Bar&quot;,&quot;label&quot;, &q...
Determine Type of Synchronization (Change in Object Property/State) 2 obj_wait_info (&quot;Bar&quot;,&quot;label&quot;, &q...
Determine Type of Synchronization (Waiting for a Bitmap) 2 obj_wait_bitmap (&quot;Window&quot;, &quot;Img1&quot;, 10, 209,...
Determine Type of Synchronization (Waiting for a Bitmap) 2 obj_wait_bitmap (&quot;Window&quot;, &quot;Img1&quot;, 10, 209,...
Determine Type of Synchronization (Waiting for a Bitmap) 2 obj_wait_bitmap (&quot;Window&quot;, &quot;Img1&quot;, 10, 209,...
How Long Does It Wait? &quot;OK&quot; &quot;Error&quot; TIME PARAMETER Global timeout setting Global timeout interval GLOB...
Add Synchronization to Test Script Wait for a Window 3 # Login set_window  ( &quot;Login&quot; ,4); edit_set  ( &quot;Agen...
Add Synchronization to Test Script Wait for a Window # Login set_window  ( &quot;Login&quot; ,4); edit_set  ( &quot;Agent ...
Add Synchronization to Test Script Wait for an Object State/Property Value list_select_item  ( &quot;Fly From:&quot;,&quot...
Add Synchronization to Test Script Wait for an Object State/Property Value list_select_item  ( &quot;Fly From:&quot;,&quot...
Add Synchronization to Test Script Wait for an Object State/Property Value list_select_item  ( &quot;Fly From:&quot;,&quot...
Add Synchronization to Test Script Wait for an Object State/Property Value list_select_item  ( &quot;Fly From:&quot;,&quot...
Add Synchronization to Test Script Wait for an Object State/Property Value list_select_item  ( &quot;Fly From:&quot;,&quot...
Add Synchronization to Test Script Wait for a Bitmap Area 3 # Mercury Homepage set_window  (  &quot;Mercury Homepage&quot;...
Add Synchronization to Test Script Wait for a Bitmap Area # Mercury Homepage set_window  (  &quot;Mercury Homepage&quot; ,...
Add Synchronization to Test Script Wait for a Bitmap Area 3 # Mercury Homepage set_window  (  &quot;Mercury Homepage&quot;...
Add Synchronization to Test Script Wait for a Bitmap Area 3 # Mercury Homepage set_window  (  &quot;Mercury Homepage&quot;...
Other Object State Synchronization Statements <ul><li>button_wait_info </li></ul><ul><li>edit_wait_info </li></ul><ul><li>...
Play Back Revised Script 4 edit_set (&quot;Date&quot;,&quot;070703&quot;); list_select_item (&quot;Fly From:&quot;, &quot;...
Play Back Revised Script 4 07/07/03 Los Angeles Denver Cash edit_set (&quot;Date&quot;,&quot;070703&quot;); list_select_it...
Play Back Revised Script 4 edit_set  ( &quot;Date&quot;,&quot;070703&quot; ); list_select_item  ( &quot;Fly From:&quot;, &...
Summary <ul><li>The AUT's performance may slow down as the number of users increases </li></ul><ul><li>Synchronization poi...
LAB EXERCISE
<ul><li>Create Bitmap Synchronization  for Insert Order Image  </li></ul><ul><li>Add Synchronization points to all INSERT,...
Enhancing Your Test Using TSL   Test Script Language
Enhancing Your Test Using TSL <ul><li>In this lesson you will learn: </li></ul><ul><li>How TSL can enhance test scripts: <...
What is TSL ? <ul><li>It is a C-like language </li></ul><ul><ul><li>flow control (for, while, if / else…, switch) </li></u...
Variables and Constants <ul><li>Use variables and constants to: </li></ul><ul><ul><li>remove hard-coded data for maintaina...
Variables and Constants    Variable and Constant Names: -  letters, numbers, underscore -  first character must be a lette...
Variables and Constants  Strings and Numbers number1 =  &quot;4&quot; ; number2 =  3 ; value = number1 * number2; value co...
Variables and Constants  Special Characters in Strings <ul><li>The backslash is used to start an escape-sequence, (a speci...
Arrays <ul><li>Use arrays when you need to store many data values using one data structure </li></ul><ul><ul><li>allow for...
Arrays Simple Array fltclass[ 1 ]=  &quot;First&quot; ; fltclass[ 2 ]=  &quot;Business&quot; ; fltclass[ 3 ]=  &quot;Econo...
Arrays Associative Array userdata[ &quot;name&quot; ]=  &quot;John Smith&quot; ; userdata[ &quot;address&quot; ]=  &quot;1...
Arrays Multi-dimensional Arrays flightinfo[  1 ,  &quot;Date”  ] =  &quot;07/22/99&quot; ; flightinfo[  1 ,  &quot;FlyFrom...
Flow Control <ul><li>Add flow control to increase the test script’s reliability and maintainability </li></ul><ul><ul><li>...
Flow Control  Conditional Decision Making set_window (“Flight Reservation”); obj_get_info (“Order No:”, “value”, OrderNo);...
Flow Control switch Statement set_window (&quot;Fax Order&quot;); edit_get_text (&quot;Class:&quot;, class); switch  (clas...
Flow Control for Loop # Looping for stress testing for (i=0; i<1000; i++) { set_window (“Flight Reservation”); menu_select...
Flow Control  while Loop file= &quot;c:atalight_orders.txt&quot;; file_open( file, FO_MODE_READ ); while ( file_getline( f...
Flow Control  do while Loop # Flight Reservation set_window ( &quot;Flight Reservation&quot;, 2 ); edit_set ( &quot;Name:&...
Operators <ul><li>Use operators to create expressions by combining </li></ul><ul><li>variables and constants </li></ul><ul...
Operators Arithmetic/Relational edit_get_text (&quot;Tickets&quot;, tickets);  edit_get_text (&quot;Price&quot;, price); e...
Operators Logical Operators # Value is greater than 50 AND less than 100 if ( value > 50  &&  value <100 ) tl_step (“Value...
TSL Testing Functions <ul><li>TSL contains many non-recorded testing functions to enhance your tests </li></ul><ul><ul><li...
TSL Testing Functions <ul><li>Arithmetic </li></ul><ul><ul><li>exp </li></ul></ul><ul><ul><li>int </li></ul></ul><ul><li>I...
Important TSL Functions Invoking an Application <ul><li>Description: Invokes a Windows application from within a test scri...
Important TSL Functions Checking for a Window <ul><li>Description: This statement can be used to verify if an error messag...
Important TSL String Functions Splitting a String <ul><li>Description: This statement can be used to split a long string i...
Important TSL Functions Accessing DOS <ul><li>Description: Executes a DOS command from within a test (equivalent to execut...
Important TSL Functions Input/Output <ul><li>Read input from the WinRunner Data Table </li></ul><ul><ul><li>discussed in a...
<ul><li>Description: Use tl_step function to report status of a checkpoint </li></ul><ul><ul><li>divides test into steps &...
Output to Report report_msg Statement <ul><li>Description: - Send information about the test execution to the Test Report ...
<ul><li>Functions arranged in categories </li></ul>Accessing Functions The Function Generator <ul><li>Expand form to fill ...
Accessing Functions The Editor # Automobile Purchase Form set_window ( &quot;Automobile Purchase Form&quot; , 10); edit_se...
Accessing Functions The Editor # Automobile Purchase Form set_window ( &quot;Automobile Purchase Form&quot; , 10); edit_se...
Using Return Codes <ul><li>Each TSL Function has a return code </li></ul><ul><ul><li>numeric </li></ul></ul><ul><ul><li>ge...
Debugging Tests <ul><li>Step, Step Into </li></ul><ul><li>Breakpoint </li></ul><ul><li>Watch Variables </li></ul><ul><li>p...
Debugging Tests pause Statement <ul><li>Halts execution of test script and pops up a message box </li></ul><ul><li>Ensures...
Comments <ul><li>WinRunner ignores anything after a “#” as a comment </li></ul><ul><li>Thoroughly comment test scripts for...
Creating a Startup Script <ul><li>A startup script can contain anything you want executed each time you start WinRunner </...
Creating a Startup Script ############################################ #  TestSuite Training Init Test  # ################...
Summary <ul><li>Enhance your script using TSL </li></ul><ul><ul><li>add logic (flow control, variables, operators) </li></...
LAB EXERCISE
<ul><li>Write a Script  to get the user input through default dialog box. </li></ul><ul><li>Write a function to open Fligh...
Upcoming SlideShare
Loading in...5
×

WinRunner Training

35,058

Published on

Win Runner Training - Good One

Published in: Business, Technology
33 Comments
20 Likes
Statistics
Notes
No Downloads
Views
Total Views
35,058
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
0
Comments
33
Likes
20
Embeds 0
No embeds

No notes for slide
  • Transcript of "WinRunner Training"

    1. 1. Winrunner Training Objective of the Course <ul><li>Understand the benefits of automated testing </li></ul><ul><li>To get an insight into the working of automated test tools </li></ul><ul><li>To use and understand the features of Winrunner </li></ul><ul><li>Creation of test scripts using Winrunner </li></ul>
    2. 2. Benefits of Automated Testing WinRunner Testing Process WinRunner Recording Mode Working with other Test Suite Tools
    3. 3. Manual Vs. Automated Testing <ul><li>Manual Testing: </li></ul><ul><li>Is time-consuming and tedious </li></ul><ul><li>Requires a heavy investment in human resources </li></ul><ul><li>Time constraints often make it impossible to manually test every feature thoroughly before the software is released </li></ul><ul><li>Automated Testing: </li></ul><ul><li>Dramatically speed up the testing process </li></ul><ul><li>Creation of test scripts which check all aspects of the application </li></ul><ul><li>Execute these tests on each new build </li></ul>
    4. 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. 5. WinRunner Testing Process <ul><li>1 Create the GUI Map </li></ul><ul><ul><li>WinRunner must learn to recognize the objects in an application in order to run tests </li></ul></ul><ul><ul><li>The preferred way to teach WinRunner your objects depends on the GUI map mode </li></ul></ul><ul><li>2 Create Tests </li></ul><ul><ul><li>WinRunner writes scripts automatically when recording actions in applications </li></ul></ul><ul><ul><li>One can program directly in Mercury Interactive’s Test Script Language (TSL) </li></ul></ul><ul><li>3 Debug Tests </li></ul><ul><ul><li>You debug the tests to check that they operate smoothly and without interruption </li></ul></ul>
    6. 6. WinRunner Testing Process <ul><li>4 Run Tests </li></ul><ul><ul><li>Run tests in Verify mode to test your application </li></ul></ul><ul><ul><li>It compares the current data of the application being tested to the expected data captured earlier </li></ul></ul><ul><ul><li>If any mismatches are found, WinRunner captures them as actual results </li></ul></ul><ul><li>5 View Results </li></ul><ul><ul><li>After each test run, WinRunner displays the results in a report </li></ul></ul><ul><ul><li>The report details all the major events that occurred during the run, such as checkpoints, error messages, system messages, or user messages </li></ul></ul><ul><li>6 Report Defects </li></ul><ul><ul><li>If a test run fails due to a defect in the application being tested it can be reported directly from the Test Results window </li></ul></ul><ul><ul><li>This information is sent via e-mail to the quality assurance manager, who tracks the defect until it is fixed </li></ul></ul>
    7. 7. Recording Mode <ul><li>Context Sensitivity </li></ul><ul><li>Context Sensitivity records operations in terms of GUI objects. </li></ul><ul><li>For e.g. </li></ul><ul><li>if you record a mouse click on OK button. WinRunner generates following TSL statements- </li></ul><ul><li>Analog Mode </li></ul><ul><li>Analog Mode Records the exact coordinates traveled by the mouse </li></ul><ul><li>For e.g. </li></ul><ul><li>if you record a mouse click on OK button. WinRunner generates following TSL statements </li></ul>button_press (“ OK ”); move_locator_track (1); mtype (&quot;<T110><kLeft>-&quot;); mtype (&quot;<kLeft>+&quot;);
    8. 8. Choosing a Recording Mode <ul><li>Choose Context Sensitive if... </li></ul><ul><li>The application contains GUI objects </li></ul><ul><li>Exact mouse movements are not required </li></ul><ul><li>You plan to reuse the test in different versions of the application </li></ul><ul><li>Choose Analog if... </li></ul><ul><li>The application contains bitmap areas (such as a drawing area) </li></ul><ul><li>Exact mouse movements are required </li></ul>
    9. 9. <ul><li>Starting WinRunner </li></ul><ul><ul><li>To start WinRunner, click Start > Programs > WinRunner > WinRunner </li></ul></ul>Recording User Actions
    10. 10. <ul><li>Creating a New test </li></ul><ul><ul><li>Click on New Test </li></ul></ul>Recording User Actions
    11. 11. WinRunner Main Window
    12. 12. WinRunner Standard Toolbar
    13. 13. Recording a Test <ul><li>To Record a Test in WinRunner, Select the Record Button from the Standard Toolbar </li></ul>
    14. 14. Recording a Test <ul><li>Open the Application and Enter the Data </li></ul>Automatic Script Generation Enter Application Data
    15. 15. Benefits of Automated Testing WinRunner Testing Process WinRunner Recording Mode Working with other Test Suite Tools
    16. 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 <ul><li>Test Director : Software Test Management Tool </li></ul><ul><ul><li>Creation of a database of manual and automated tests, building of test cycles, running tests, and report and track defects </li></ul></ul><ul><ul><li>With WinRunner, tests can be directly saved into the Test Director database </li></ul></ul><ul><ul><li>Tests can be executed in WinRunner and the overall results can be reviewed in Test Director </li></ul></ul><ul><li>Load Runner : Testing tool for Client/Server Applications </li></ul><ul><ul><li>Using Load Runner, you can emulate an environment in which many users (virtual users) are simultaneously engaged in a single server application </li></ul></ul><ul><ul><li>You can test an application’s performance “under load” by simultaneously activating virtual users on multiple host computers. </li></ul></ul>
    17. 17. Summary <ul><li>Advantages of Automated Testing over Manual Testing (Fast, Reliable, Repeatable, Programmable, Comprehensive, Reusable) </li></ul><ul><li>The WinRunner Testing Process </li></ul><ul><ul><li>Creating the GUI Map,Creating Tests,Debugging Tests,Running Tests,Viewing Results, Reporting Defects </li></ul></ul><ul><li>WinRunner Recording Modes (Context Sensitivity,Analog) </li></ul><ul><li>Recording a Test </li></ul><ul><li>Working with other Test Suite Tools (Test Director, Load Runner) </li></ul>
    18. 18. LAB EXERCISE
    19. 19. <ul><li>Record Login Process from Flight Reservation Sample Application in Context Sensitivity Mode </li></ul><ul><li>Record Flight Reservation Sample Application for Insert Order,Open Order and Fax Order </li></ul><ul><li>Record Burger Application for Order Entry Box </li></ul>
    20. 20. Day 2 <ul><li>Topic </li></ul><ul><li>Setting up GUI Map </li></ul><ul><li>Managing GUI Map </li></ul><ul><li>Using the Rapid Test Script Wizard </li></ul>
    21. 21. How Does WinRunner Create the Script?
    22. 22. How Does WinRunner Create the Script? John set_window(&quot;Login&quot;, 10); edit_set (&quot;Name&quot;, ”John&quot;); Recording WinRunner AUT <ul><li>WinRunner adds windows and objects to the GUI Map as they are encountered by the user during recording </li></ul><ul><li>The GUI Map contains information that allows WinRunner TSL statements to be translated into Windows commands, and vice versa </li></ul>GUI Map
    23. 23. How Does WinRunner Run the Script? set_window(&quot;Login&quot;, 10); edit_set (&quot;Name&quot;, ”John&quot;); John Playback WinRunner AUT <ul><li>When WinRunner executes a TSL statement, it passes through the GUI Map before being sent to Windows </li></ul><ul><li>The application’s response must pass through the GUI Map also </li></ul>GUI Map
    24. 24. Main Issues in Script Creation <ul><li>Unique Identification of objects </li></ul><ul><ul><li>WinRunner must uniquely identify each object in the Graphical User Interface (GUI) of the application </li></ul></ul><ul><li>Naming of objects </li></ul><ul><ul><li>How will WinRunner refer to GUI objects in the application? (&quot;Press the OK button in the Open window&quot;) </li></ul></ul>
    25. 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. 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. 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. 28. Into Which Field Will WinRunner Play Back? set_window(&quot;Login&quot;, 10); edit_set (&quot;Name:&quot;, &quot;John&quot;); John ? ?
    29. 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. 30. WinRunner Tracks AUT’s Windows and Objects With the GUI Map File <ul><li>The GUI Map file contains the: </li></ul><ul><li>Windows of the AUT </li></ul><ul><li>Objects within each window </li></ul><ul><li>Physical attributes that create each object’s unique identification </li></ul>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. 31. GUI Map Editor <ul><li>Visual tree displays windows and objects contained in the GUI Map File </li></ul><ul><li>First level consists of all windows in AUT </li></ul><ul><li>Second level consists of objects uniquely identified within each parent window </li></ul>Parent Window (logical name) Physical Description of window or object highlighted above Child Objects (logical names)
    32. 32. The GUI Map <ul><li>Allows separation of physical attributes from test scripts </li></ul><ul><li>Enables WinRunner to uniquely identify objects in the AUT using physical attributes </li></ul><ul><li>Allows WinRunner to refer to objects in the script using an intuitive logical name </li></ul><ul><li>Provides the connection between logical names and physical attributes </li></ul><ul><li>Maintainability </li></ul><ul><ul><li>If a button label changes in the application, update the button description once in the GUI map rather than in 500 tests </li></ul></ul><ul><li>Readability </li></ul><ul><ul><li>button_press(&quot;Insert&quot;) instead of button_press(&quot;{class: ThunderSSCommand}&quot;); </li></ul></ul><ul><li>Portability </li></ul><ul><ul><li>Use the same script for all platforms, with a different GUI map for each platform </li></ul></ul>Characteristics Strengths
    33. 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. 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. 35. Playback Example <ul><ul><li>Save As </li></ul></ul>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. 36. Summary <ul><li>WinRunner uniquely identifies every object in the AUT by its physical description </li></ul><ul><li>Each object is uniquely identified within the scope of its parent window (not the entire application) </li></ul><ul><li>WinRunner references each object in the script using a logical name </li></ul><ul><li>Objects and their descriptions are stored in a GUI Map File </li></ul><ul><li>The GUI Map File can be viewed in the GUI Map Editor </li></ul>
    37. 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. 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. 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. 40. Creating a Permanent GUI Map File Car_App.gui L1 Car_App.gui Insert Test1 Test2 Testing Project Tests GUI Technique 1
    41. 41. Adding New Windows and Objects to a GUI Map File Invoke the GUI Map Editor 1 Technique 1
    42. 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. 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. 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. 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. 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. 47. Creating a Permanent GUI Map File Technique 2 Invoke the GUI Map Editor 1
    48. 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. 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. 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. 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. 52. Modify Names for Script Readability These names are unreadable. To what objects do they refer ? Technique 2
    53. 53. Modify Names for Script Readability Technique 2 Highlight the object whose name you want to change 1
    54. 54. Modify Names for Script Readability Technique 2 Highlight the object whose name you want to change 1 Click the Modify Button 2
    55. 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. 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. 57. Creating a Permanent GUI Map File Car_App.gui L1 Car_App.gui Insert Test1 Test2 Testing Project Tests GUI Technique 2
    58. 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. 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. 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. 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. 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. 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. 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. 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. 66. Custom User Toolbar <ul><li>The Custom User Toolbar feature allows you to customize WinRunner’s UI to suit your testing needs </li></ul><ul><li>Create shortcuts to frequently used WinRunner menu commands </li></ul><ul><li>Paste TSL statements into your test scripts </li></ul><ul><li>Execute TSL statements </li></ul>
    67. 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. 68. Summary <ul><li>Two methods to manage GUI Map files </li></ul><ul><ul><li>1 GUI Map per test </li></ul></ul><ul><ul><ul><li>if AUT is not expected to change </li></ul></ul></ul><ul><ul><ul><li>easiest way to create a GUI Map file </li></ul></ul></ul><ul><ul><li>1 GUI Map for many tests </li></ul></ul><ul><ul><ul><li>if changes to AUT are expected </li></ul></ul></ul><ul><ul><ul><li>most easily maintained </li></ul></ul></ul><ul><li>Use the GUI Map Editor to fix GUI Map file problems </li></ul>
    69. 69. LAB EXERCISE
    70. 70. <ul><li>Use GUI Spy to learn the objects </li></ul><ul><li>Record Flight Application Sample and Save the temporary GUI Map file and Load the same GUI Map file (Use function) </li></ul><ul><li>Create GUI Map for the same Using Learn option </li></ul><ul><li>Merge Login and Flight Application GUI Map file into a single one </li></ul><ul><li>Create a GUI Map File for Burger Application using the Learn option </li></ul>
    71. 71. Day 3 <ul><li>Topic </li></ul><ul><li>Introduction to Verification </li></ul><ul><li>GUI Checkpoints </li></ul><ul><li>Database Checkpoints </li></ul><ul><li>Bitmap Checkpoints </li></ul><ul><li>Text Checkpoints </li></ul>
    72. 72. Verification GUI Checkpoints Database Checkpoints Bitmap Checkpoints Text Checkpoints
    73. 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. 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. 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. 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. 77. What Is WinRunner Verification? Definition: Verification is the process by which WinRunner reports whether expected results are actualized by the application.
    78. 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. 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. 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. 81. Playback - Run Modes <ul><li>DEBUG To check for errors in the script (Results folder: debug ) </li></ul><ul><li>VERIFY To test the application and verify the result (Results folder: res1 (default); user can rename) </li></ul><ul><li>UPDATE To overwrite the expected result with a new value (Results folder: exp ) </li></ul>
    82. 82. GUI Object Verification <ul><li>Is the window the correct size? </li></ul><ul><li>Is the OK button enabled? </li></ul><ul><li>What is the content of the Name field? </li></ul>Check the state or attributes of GUI objects:
    83. 83. Database Verification <ul><li>Check the contents and dimensions of a database </li></ul><ul><li>Directly verify database-related transactions </li></ul>
    84. 84. Bitmap Image Verification <ul><li>Check non-GUI object areas of the application by capturing a bitmap </li></ul><ul><li>Capture bitmap of window, object, or area of screen </li></ul>
    85. 85. Text Verification <ul><li>Read and verify text from bitmap areas or non-GUI object based interfaces (e.g., ASCII) </li></ul>
    86. 86. Summary <ul><li>Verification allows WinRunner to check the AUT's behavior </li></ul><ul><li>Types of verification checks </li></ul><ul><ul><li>GUI objects </li></ul></ul><ul><ul><li>databases </li></ul></ul><ul><ul><li>bitmap images </li></ul></ul><ul><ul><li>text </li></ul></ul><ul><li>Use GUI Object verification whenever possible, because it is the most reliable </li></ul>
    87. 87. Verification GUI Checkpoints Database Checkpoints Bitmap Checkpoints Text Checkpoints
    88. 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. 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. 90. Process for GUI checkpoints 1 Determine the visual cue(s)
    91. 91. Which visual cues demonstrate that the AUT meets requirements <ul><li>Flight Reservation Order information form </li></ul><ul><li>On click of Insert Order </li></ul><ul><li>… a visual cue is given by the application </li></ul>Application returns a message Application returns a value Object changes its state GUI object example
    92. 92. Determine which visual cues to verify ? <ul><li>Edit Field </li></ul><ul><ul><li>Compare </li></ul></ul><ul><ul><li>Enabled </li></ul></ul><ul><ul><li>Focus </li></ul></ul><ul><ul><li>Range </li></ul></ul><ul><li>Check Button </li></ul><ul><ul><li>Enabled </li></ul></ul><ul><ul><li>Focus </li></ul></ul><ul><ul><li>Label </li></ul></ul><ul><li>Pushbutton </li></ul><ul><ul><li>Enabled </li></ul></ul><ul><ul><li>Focus </li></ul></ul><ul><ul><li>Label </li></ul></ul><ul><ul><li>Width </li></ul></ul><ul><ul><li>Height </li></ul></ul>
    93. 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. 94. Process for GUI checkpoints Create GUI checkpoint 2 1 Determine the visual cue(s)
    95. 95. Create GUI Checkpoints <ul><li>Select Checkpoint to fit the verification </li></ul>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. 96. Check One property of one Object <ul><li>Select GUI Checkpoint for single property </li></ul>set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
    97. 97. Check One property of one Object <ul><li>Select GUI Checkpoint for single property </li></ul>button_check_info (“OK”,”enabled”,0); <ul><li>Point to the Object </li></ul><ul><li>WinRunner inserts button_check_info statement into the recorded Test Script </li></ul>set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
    98. 98. Check Multiple properties of one Object <ul><li>Select GUI Checkpoint for Object/Window </li></ul>set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
    99. 99. Check Multiple properties of one Object <ul><li>Select GUI Checkpoint for Object/Window </li></ul>obj_check_gui ( &quot;OK&quot; , &quot;list1.ckl&quot; , &quot;gui1&quot; , 1 ); <ul><li>Point to the Object </li></ul><ul><li>Select Multiple properties for the objects </li></ul>set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
    100. 100. Check Multiple properties of one Object <ul><li>Select GUI Checkpoint for Object/Window </li></ul>obj_check_gui ( &quot;OK&quot; , &quot;list1.ckl&quot; , &quot;gui1&quot; , 1 ); <ul><li>Point to the Object </li></ul><ul><li>Select Multiple properties for the objects </li></ul><ul><li>WinRunner inserts a obj_check_gui statement </li></ul>set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
    101. 101. Check Multiple properties of multiple Objects <ul><li>Select GUI Checkpoint for Multiple Objects </li></ul>set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
    102. 102. Check Multiple properties of multiple Objects <ul><li>Select GUI Checkpoint for Multiple Objects </li></ul><ul><li>Click Add and point to the object </li></ul>set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
    103. 103. Check Multiple properties of multiple Objects <ul><li>Select GUI Checkpoint for Multiple Objects </li></ul><ul><li>Click Add and point to the object </li></ul><ul><li>Select Multiple properties for multiple objects </li></ul>set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
    104. 104. Check Multiple properties of multiple Objects <ul><li>Select GUI Checkpoint for Multiple Objects </li></ul>win_check_gui ( &quot;Login&quot; , &quot;list2.ckl&quot; , &quot;gui2&quot; , 1 ); <ul><li>Point to the Object </li></ul><ul><li>Select Multiple properties for multiple objects </li></ul><ul><li>WinRunner inserts a win_check_gui statement </li></ul>set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
    105. 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. 106. Test the checkpoint <ul><li>Checkpoint should work for both ‘Pass’ and ‘Fail’ condition </li></ul><ul><li>Set the object to a state that should ‘Pass’ </li></ul><ul><li>Step through the checkpoint in Debug mode </li></ul><ul><li>Set the object to a state that should ‘Fail’ (Reverse the object state) </li></ul><ul><li>Step through the checkpoint again </li></ul><ul><li>Verify correct execution </li></ul>
    107. 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. 108. Verify correct Script Execution <ul><li>After successfully testing the Checkpoints for ‘Pass’ and ‘Fail’ conditions </li></ul><ul><li>We are ready to run the entire Script </li></ul><ul><li>Script should run without error </li></ul><ul><li>When Script is ok, we are ready to test the application under test (AUT) </li></ul>
    109. 109. Test directory after GUI Checkpoint Testing Project Tests chklist List1.ckl exp Test2 gui1.chk Test1 Test2
    110. 110. Summary <ul><li>GUI Checkpoint can verify </li></ul><ul><ul><li>One property of one object </li></ul></ul><ul><ul><li>Multiple properties of one objects </li></ul></ul><ul><ul><li>One or more properties of several objects </li></ul></ul><ul><li>Expected results are stored in exp folder </li></ul><ul><li>Actual results are stored in results folder </li></ul>
    111. 111. Verification GUI Checkpoints Database Checkpoints Bitmap Checkpoints Text Checkpoints
    112. 112. Database Checkpoint Definition: A test script checkpoint which verifies the schema table contains the expected data
    113. 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. 114. Queries Extract Data <ul><li>Select Order_Number from Orders Where Flight_Number = ‘19075’ </li></ul>11 Order_Number
    115. 115. Why use Database Checkpoints ? <ul><li>Does the AUT insert , update and delete records correctly </li></ul><ul><li>Do the new versions of the database function properly </li></ul><ul><li>Does the AUT maintain referential integrity </li></ul>
    116. 116. What can you check in a Database ? <ul><li>No of Columns </li></ul><ul><li>No of Rows </li></ul><ul><li>Data content of the tables </li></ul>
    117. 117. How does WinRunner Query the Data ? <ul><li>WinRunner integrates with MS Query or a Data Junction </li></ul><ul><li>MS Query is used to create a query to extract data </li></ul><ul><li>The query is used by WinRunner to capture the expected and actual values from the table(s) </li></ul>
    118. 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. 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. 120. Process for Database Checkpoints 1 Record User actions to create database transaction
    121. 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. 122. Process for Database Checkpoints Use Database Checkpoint wizard to implement the database checkpoint 2 1 Record User actions to create database transaction
    123. 123. Use Database Checkpoint Wizard <ul><li>Select Database Checkpoint for default check </li></ul>set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
    124. 124. Use Database Checkpoint Wizard <ul><li>Select Database Checkpoint for default check </li></ul><ul><li>Create a Query to extract data </li></ul>
    125. 125. Use Database Checkpoint Wizard <ul><li>Select Database Checkpoint for default check </li></ul>db_check ( &quot;list1.cdl&quot; , &quot;dbvf1&quot; ); <ul><li>Create a Query to extract data </li></ul><ul><li>WinRunner inserts a db_check statement </li></ul>set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
    126. 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. 127. Test the checkpoint <ul><li>Checkpoint should work for both ‘Pass’ and ‘Fail’ condition </li></ul><ul><li>Set the database to a state that should ‘Pass’ </li></ul><ul><li>Step through the checkpoint in Debug mode </li></ul><ul><li>Set the database to a state that should ‘Fail’ (Reverse the object state) </li></ul><ul><li>Step through the checkpoint again </li></ul><ul><li>Verify correct execution </li></ul>
    128. 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. 129. Verify correct Script Execution <ul><li>After successfully testing the Checkpoints for ‘Pass’ and ‘Fail’ conditions </li></ul><ul><li>We are ready to run the entire Script </li></ul><ul><li>Script should run without error </li></ul><ul><li>When Script is ok, we are ready to test the application under test (AUT) </li></ul>
    130. 130. Test directory after Database Checkpoint Testing Project Tests chklist list1.cdl msqr1.sql exp Test2 dbvf1 Test1 Test2
    131. 131. Summary <ul><li>Use Database Checkpoints to verify data in the Database </li></ul><ul><li>Use MS Query to extract data </li></ul><ul><li>WinRunner uses Query to capture expected and Actual results </li></ul><ul><li>Always restore the database to its original state before each Test execution </li></ul>
    132. 132. Verification GUI Checkpoints Database Checkpoints Bitmap Checkpoints Text Checkpoints
    133. 133. Bitmap Checkpoint Definition: <ul><li>Bitmap checkpoint are non–context sensitive and are dependent upon the screen resolution </li></ul><ul><li>Color scheme (screen resolution and no of colors) </li></ul>Use Bitmap checkpoint only when verification cannot be accomplished using object or window attributes Tip
    134. 134. Is Bitmap Checkpoint necessary? Bitmap Checkpoint GUI Checkpoint <ul><li>Used to verify non-GUI Object areas e.g. Drawing Area </li></ul><ul><li>When unable to use GUI Checkpoint </li></ul><ul><li>Useful for Graphs etc. </li></ul><ul><li>Most Reliable </li></ul><ul><li>Maintainable </li></ul><ul><li>Preferred method for buttons etc. </li></ul>
    135. 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. 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. 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. 138. Create a Bitmap Checkpoint <ul><li>Create a Bitmap Checkpoint for Object/Window or a Screen Area </li></ul>set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
    139. 139. Create a Bitmap Checkpoint <ul><li>Create a Bitmap Checkpoint for Object/Window or a Screen Area </li></ul><ul><li>Point to the object </li></ul>
    140. 140. Create a Bitmap Checkpoint <ul><li>Create a Bitmap Checkpoint for Object/Window or a Screen Area </li></ul>obj_check_bitmap ( &quot;Name:&quot; , &quot;Img1&quot; , 1 ); <ul><li>Point to the Object </li></ul><ul><li>WinRunner inserts a obj_check_bitmap statement </li></ul>set_window(“Login&quot;, 2); obj_type (“Agent Name:”,”<kTab>”); edit_set (“Password&quot;, “mercury&quot;); edit_set (“Agent Name:&quot;, “Test&quot;);
    141. 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. 142. Test the checkpoint <ul><li>Checkpoint should work for both ‘Pass’ and ‘Fail’ condition </li></ul><ul><li>Set the object to a state that should ‘Pass’ </li></ul><ul><li>Step through the checkpoint in Debug mode </li></ul><ul><li>Set the object to a state that should ‘Fail’ (Reverse the object state) </li></ul><ul><li>Step through the checkpoint again </li></ul><ul><li>Verify correct execution </li></ul>
    143. 143. Verify correct Script Execution <ul><li>After successfully testing the Checkpoints for ‘Pass’ and ‘Fail’ conditions </li></ul><ul><li>We are ready to run the entire Script </li></ul><ul><li>Script should run without error </li></ul><ul><li>When Script is ok, we are ready to test the application under test (AUT) </li></ul>
    144. 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. 145. Differences are reported and the difference Bitmap is found <ul><li>Expected Result </li></ul>Actual Result Difference Bitmap
    146. 146. Summary <ul><li>Use Bitmap checkpoint for non GUI objects </li></ul><ul><li>You can define specific area of bitmap to verify </li></ul><ul><li>WinRunner captures a difference bitmap when checkpoint fails </li></ul><ul><li>Use GUI checkpoint whenever possible </li></ul>
    147. 147. Verification GUI Checkpoints Database Checkpoints Bitmap Checkpoints Text Checkpoints
    148. 148. Why use a Text Checkpoint ? <ul><li>Verify range of values </li></ul><ul><li>Calculate dynamic values </li></ul><ul><li>Branch a test according to the value read from the screen </li></ul><ul><li>Color, Font and Resolution independent </li></ul><ul><li>Reliable, Portable and Maintainable </li></ul>
    149. 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. 150. Process for Text Checkpoints 1 Define a variable in the script and assign the expected value
    151. 151. Define a variable in the script and assign the expected value <ul><li>for e.g. tickets_sold =“Total tickets sold is 26” </li></ul>
    152. 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. 153. Insert a function to read the actual text from the AUT during playback <ul><li>There are three ways to insert functions depending on the Text type </li></ul><ul><li>If Text is …. </li></ul>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. 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. 155. Insert code to compare the actual and expected value <ul><li>set_window(&quot;Graph&quot;, 1); obj_get_text(&quot;GS_Drawing&quot;, text); </li></ul><ul><li>if (text == &quot;Total Tickets Sold is 26&quot; ) report_msg(“Message is correct&quot;); else report_msg(“Message is not correct&quot;); </li></ul>
    156. 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. 157. LAB EXERCISE
    158. 158. <ul><li>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. </li></ul><ul><li>Create a Bitmap checkpoint on Order No and Graph of Flight Reservation </li></ul><ul><li>Create a text checkpoint on any of page and verify the results .Search for “Sample “ word in the application using text checkpoint. </li></ul><ul><li>Create a database checkpoint to check whether a record is inserted or not by adding checkpoint on Order No </li></ul>
    159. 159. Data Driven Tests
    160. 160. Data-Driven Tests <ul><li>In this lesson you will learn: </li></ul><ul><li>What is a data-driven test </li></ul><ul><li>How to work with Data Tables </li></ul><ul><li>How to implement a data-driven test </li></ul><ul><li>How to import data from a database </li></ul>
    161. 161. What is a Data-Driven Test? <ul><li>A test contains: </li></ul><ul><li>Actions: list_select_item(&quot;Fly From:&quot;,&quot;Denver&quot;); </li></ul><ul><li>Objects: list_select_item(&quot;Fly From:&quot;,&quot;Denver&quot;); </li></ul><ul><li>Data: list_select_item(&quot;Fly From:&quot;,&quot;Denver&quot;); </li></ul>What if you want to use different data? San Francisco Los Angeles London
    162. 162. What is a Data-Driven Test? <ul><li>Data-driven test: </li></ul><ul><li>Test is modified to read data from the Data Table </li></ul><ul><li>Data is entered in the Data Table </li></ul>“ Denver” ); Objects <ul><ul><li>list_select_item ( &quot;Fly From:”, </li></ul></ul>Recorded Value Actions Data Table ddt_val (table, fly_from) ); Data
    163. 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. 164. Advantages of a Data-Driven Test <ul><li>Run the same test with different data </li></ul><ul><li>Expandable </li></ul><ul><li>Easy to maintain </li></ul>
    165. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 175. 2. Modify Test to Read from Data Table Running the DataDriver Wizard Where does the Data Table reside? <test name> default.xls
    176. 176. 2. Modify Test to Read from Data Table Running the DataDriver Wizard How do you populate the Data Table? <ul><li>If you want to import data from a database, do it now, using the Wizard </li></ul><ul><li>Other methods will be discussed in the next section, “Move Data” </li></ul>
    177. 177. 3. Move Data to Data Table Importing Data From Database to Data Table Database
    178. 178. 3. Move Data to Data Table Importing Data From Database to Data Table Database
    179. 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. 180. 2. Modify Test to Read from Data Table Running the DataDriver Wizard
    181. 181. Data Driving Tests Create a test 1 2 3 Move data to Data Table Modify test to read from Data Table
    182. 182. 3. Move Data to Data Table How Is Data Moved to Data Table? <ul><li>Import, using DataDriver Wizard (covered in previous section) </li></ul><ul><li>Manually </li></ul><ul><li>Dynamically, during run time </li></ul>
    183. 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. 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. 185. 3. Move Data to Data Table Add Data Dynamically During Run Add column to Data Table for data to be added 1
    186. 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. 187. Summary <ul><li>Create a “template” test with single set of data </li></ul><ul><li>Modify test to read data from table </li></ul><ul><ul><li>run the Data Driver Wizard </li></ul></ul><ul><li>Move data to Data Table </li></ul><ul><ul><li>import data from a database </li></ul></ul><ul><ul><li>edit Data Table directly </li></ul></ul><ul><ul><li>add data to Data Table during run-time </li></ul></ul>
    188. 188. Exercise
    189. 189. <ul><li>Create a Data Driven test on Login and Password and Error Messages that it can generate. </li></ul><ul><li>Create Data Driven test on Customer Name field. </li></ul>
    190. 190. Lesson Objectives <ul><li>In this section, we will learn </li></ul><ul><li>the importance of synchronization for successful test playback </li></ul><ul><li>how to select the appropriate synchronization type for your script </li></ul><ul><li>how to insert synchronization into a test script </li></ul>
    191. 191. How Do Client-Server Applications Behave? Single User Database server Server response time:
    192. 192. How Do Client-Server Applications Behave? Several Users Database server Server response time:
    193. 193. How Do Client-Server Applications Behave? Many Users Database server Server response time:
    194. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 228. Other Object State Synchronization Statements <ul><li>button_wait_info </li></ul><ul><li>edit_wait_info </li></ul><ul><li>list_wait_info </li></ul><ul><li>menu_wait_info </li></ul><ul><li>obj_wait_info </li></ul><ul><li>scroll_wait_info </li></ul><ul><li>spin_wait_info </li></ul><ul><li>static_wait_info </li></ul><ul><li>statusbar_wait_info </li></ul><ul><li>tab_wait_info </li></ul>
    229. 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. 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. 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. 232. Summary <ul><li>The AUT's performance may slow down as the number of users increases </li></ul><ul><li>Synchronization points allow WinRunner to wait for the AUT, just like a real user </li></ul><ul><li>Synchronization Points wait for </li></ul><ul><ul><li>windows or bitmaps to appear </li></ul></ul><ul><ul><li>objects to change state </li></ul></ul><ul><li>Maximum wait time for a Synchronization Point is the time parameter + global timeout </li></ul>
    233. 233. LAB EXERCISE
    234. 234. <ul><li>Create Bitmap Synchronization for Insert Order Image </li></ul><ul><li>Add Synchronization points to all INSERT,DELETE operations </li></ul>
    235. 235. Enhancing Your Test Using TSL Test Script Language
    236. 236. Enhancing Your Test Using TSL <ul><li>In this lesson you will learn: </li></ul><ul><li>How TSL can enhance test scripts: </li></ul><ul><ul><li>maintainability </li></ul></ul><ul><ul><li>readability </li></ul></ul><ul><ul><li>reliability </li></ul></ul><ul><ul><li>portability </li></ul></ul><ul><li>Some important TSL functions </li></ul><ul><li>How to insert TSL statements into your script using the Function Generator </li></ul>
    237. 237. What is TSL ? <ul><li>It is a C-like language </li></ul><ul><ul><li>flow control (for, while, if / else…, switch) </li></ul></ul><ul><ul><li>case sensitive </li></ul></ul><ul><ul><li>operators (arithmetic, relational…) </li></ul></ul><ul><ul><li>input/output </li></ul></ul><ul><li>It is a Basic-like language </li></ul><ul><ul><li>constants, variables, arrays </li></ul></ul><ul><li>It is interpreted for easy debugging </li></ul><ul><li>It has built-in Testing Functions </li></ul><ul><ul><li>recorded </li></ul></ul><ul><ul><li>programmed </li></ul></ul>
    238. 238. Variables and Constants <ul><li>Use variables and constants to: </li></ul><ul><ul><li>remove hard-coded data for maintainability, readability </li></ul></ul><ul><ul><li>store data (i.e., input/output data, error codes) </li></ul></ul><ul><ul><li>create data driven tests </li></ul></ul><ul><li>Variables do not have to be declared </li></ul><ul><ul><li>they can always contain strings or numbers </li></ul></ul><ul><li>Variables and constants can be of type public or static </li></ul><ul><ul><li>public: available to all tests and function libraries </li></ul></ul><ul><ul><li>static: available to only the script in which it is declared </li></ul></ul>
    239. 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. 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. 241. Variables and Constants Special Characters in Strings <ul><li>The backslash is used to start an escape-sequence, (a special character) </li></ul><ul><ul><li> Tab </li></ul></ul><ul><ul><li> Return, Newline </li></ul></ul><ul><ul><li>” Quotes </li></ul></ul><ul><li>To Insert a backslash into a string use a double backslash </li></ul><ul><ul><li>Backslash </li></ul></ul>value = &quot;This is a &quot;String&quot; with very special character&quot; ; pause ( value );
    242. 242. Arrays <ul><li>Use arrays when you need to store many data values using one data structure </li></ul><ul><ul><li>allow for easy access to large sets of data </li></ul></ul><ul><ul><li>allow for storing sets of data </li></ul></ul><ul><li>Array size can be dynamically increased </li></ul><ul><ul><li>test script expandability </li></ul></ul><ul><li>Each array element can be indexed by a user-defined string (associative arrays) </li></ul><ul><li>Multi-dimensional arrays are supported </li></ul>
    243. 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. 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. 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. 246. Flow Control <ul><li>Add flow control to increase the test script’s reliability and maintainability </li></ul><ul><ul><li>make decisions in a test script </li></ul></ul><ul><ul><li>handle predictable AUT behavior </li></ul></ul><ul><ul><li>iterate repeated user actions </li></ul></ul><ul><ul><li>handle multiple window paths in AUT </li></ul></ul><ul><ul><li>create a data driven test </li></ul></ul><ul><li>Flow control constructs: </li></ul><ul><ul><li>conditional </li></ul></ul><ul><ul><li>looping </li></ul></ul><ul><ul><li>flow modification </li></ul></ul>
    247. 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. 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. 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. 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. 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. 252. Operators <ul><li>Use operators to create expressions by combining </li></ul><ul><li>variables and constants </li></ul><ul><li>Arithmetic ( + - * / % ++ -- ) </li></ul><ul><li>Assignment ( = += -= *= /= %= ^= ) </li></ul><ul><li>Concatenation ( & ) </li></ul><ul><li>Conditional ( ? ) </li></ul><ul><li>Logical ( && || ! ) </li></ul><ul><li>Relational ( > >= < <= == != ) </li></ul>
    253. 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. 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. 255. TSL Testing Functions <ul><li>TSL contains many non-recorded testing functions to enhance your tests </li></ul><ul><ul><li>arithmetic, string </li></ul></ul><ul><ul><li>Data Table (discussed in a later lesson) </li></ul></ul><ul><ul><li>Test Report, file, query functions </li></ul></ul><ul><ul><li>synchronization </li></ul></ul><ul><ul><li>system </li></ul></ul><ul><li>Finding out about functions </li></ul><ul><ul><li>Function Generator </li></ul></ul><ul><ul><li>on-line help </li></ul></ul><ul><ul><li>TSL Reference manual </li></ul></ul><ul><ul><li>WinRunner Books Online </li></ul></ul>
    256. 256. TSL Testing Functions <ul><li>Arithmetic </li></ul><ul><ul><li>exp </li></ul></ul><ul><ul><li>int </li></ul></ul><ul><li>Input/Output </li></ul><ul><ul><li>tl_step </li></ul></ul><ul><ul><li>file_getline </li></ul></ul><ul><ul><li>file_printf </li></ul></ul><ul><li>Query GUI Objects </li></ul><ul><ul><li>edit_get_text </li></ul></ul><ul><ul><li>obj_get_info </li></ul></ul><ul><ul><li>win_exists </li></ul></ul><ul><li>String/File </li></ul><ul><ul><li>substr </li></ul></ul><ul><ul><li>file_compare </li></ul></ul><ul><li>Synchronization </li></ul><ul><ul><li>list_wait_info </li></ul></ul><ul><ul><li>obj_wait_info </li></ul></ul><ul><li>System </li></ul><ul><ul><li>invoke_application </li></ul></ul><ul><ul><li>dos_system </li></ul></ul><ul><ul><li>get_time </li></ul></ul>Examples
    257. 257. Important TSL Functions Invoking an Application <ul><li>Description: Invokes a Windows application from within a test script </li></ul><ul><li>Format: invoke_application (file, option, working_dir, show); </li></ul>app_path= “c:ercuryinrunneramples”; invoke_application (app_path & “light1a.exe”,“”, app_path, SW_SHOW); Example
    258. 258. Important TSL Functions Checking for a Window <ul><li>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. </li></ul><ul><li>Format: win_exists( window, [time] ); </li></ul>If ( win_exists ( “Flight Message” ) == E_OK ) { set_window( “Flight Message”, 2 ); button_press( “OK” ); } Example
    259. 259. Important TSL String Functions Splitting a String <ul><li>Description: This statement can be used to split a long string into smaller parts, at every appearance of a given Separator. </li></ul><ul><li>Format: split(String, Array, Field Separator); </li></ul>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. 260. Important TSL Functions Accessing DOS <ul><li>Description: Executes a DOS command from within a test (equivalent to executing a command from a DOS window) </li></ul><ul><li>Format: dos_system (expression); </li></ul>dos_system ( &quot;del c:emo.tmp” ); Example
    261. 261. Important TSL Functions Input/Output <ul><li>Read input from the WinRunner Data Table </li></ul><ul><ul><li>discussed in a later lesson </li></ul></ul><ul><li>Send output from test: </li></ul><ul><ul><li>to the report </li></ul></ul><ul><ul><li>to TestDirector </li></ul></ul>
    262. 262. <ul><li>Description: Use tl_step function to report status of a checkpoint </li></ul><ul><ul><li>divides test into steps & sends a message on success / failure </li></ul></ul><ul><ul><li>affects test status (pass / fail) </li></ul></ul><ul><ul><li>makes analysis of test script execution easier </li></ul></ul><ul><li>Format: tl_step (step_name, status, description); </li></ul>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. 263. Output to Report report_msg Statement <ul><li>Description: - Send information about the test execution to the Test Report - Does not affect test status. </li></ul><ul><li>Format: report_msg (string); </li></ul>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. 264. <ul><li>Functions arranged in categories </li></ul>Accessing Functions The Function Generator <ul><li>Expand form to fill in argument values </li></ul><ul><li>Paste into script (or execute) </li></ul><ul><li>Point and click programming </li></ul>
    265. 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 <ul><li>When you type an underscore, a list with functions will appear </li></ul><ul><li>Type ESC to hide the function list </li></ul><ul><li>Continue typing to pre-select other functions </li></ul><ul><li>TAB, ENTER or SPACE selects the actual function </li></ul>
    266. 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” <ul><li>When you type an open bracket a ToolTip with the parameters will appear </li></ul>edit_set (Edit Object, New String) edit_set ( ”Password”, “Mercury” );
    267. 267. Using Return Codes <ul><li>Each TSL Function has a return code </li></ul><ul><ul><li>numeric </li></ul></ul><ul><ul><li>general TSL error codes (E_OK, E_NOT_FOUND) </li></ul></ul><ul><li>Enhance the readability of your test scripts </li></ul><ul><ul><li>if (win_exists (&quot;Flight Reservation Message&quot;) == E_OK ) { </li></ul></ul><ul><ul><li>set_window (&quot;Flight Reservation Message&quot;); </li></ul></ul><ul><ul><li>button_press (&quot;No&quot;); </li></ul></ul><ul><ul><li>} </li></ul></ul><ul><ul><li>rc = set_window (“Flight Reservation”, 10); </li></ul></ul><ul><ul><li>if ( rc != E_OK) { </li></ul></ul><ul><ul><li>report_msg (“Flight application did not invoke properly.”); </li></ul></ul><ul><ul><li>texit (-1); # Aborting test </li></ul></ul><ul><ul><li>} </li></ul></ul>Example 2 Example 1
    268. 268. Debugging Tests <ul><li>Step, Step Into </li></ul><ul><li>Breakpoint </li></ul><ul><li>Watch Variables </li></ul><ul><li>pause Statement </li></ul>
    269. 269. Debugging Tests pause Statement <ul><li>Halts execution of test script and pops up a message box </li></ul><ul><li>Ensures that variables and arrays contain the correct data </li></ul>Capital = &quot;Sacramento&quot;; pause (&quot;The capital of California is &quot; & Capital);
    270. 270. Comments <ul><li>WinRunner ignores anything after a “#” as a comment </li></ul><ul><li>Thoroughly comment test scripts for readability and maintainability </li></ul><ul><li>Helps other test developers analyze and edit test scripts </li></ul>################################################################## # 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. 271. Creating a Startup Script <ul><li>A startup script can contain anything you want executed each time you start WinRunner </li></ul><ul><ul><li>When working within a team you can use the same startup script to ensure everyone’s environment is similar </li></ul></ul><ul><ul><li>Set the location of your Startup script in WinRunner’s General Options </li></ul></ul><ul><li>Use a startup script to: </li></ul><ul><ul><li>Load your GUI map </li></ul></ul><ul><ul><li>Declare constants and variables </li></ul></ul><ul><ul><li>Load your Function Libraries </li></ul></ul><ul><ul><li>Customize your Function Generator </li></ul></ul><ul><ul><li>Configure WinRunner’s view of objects </li></ul></ul>
    272. 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. 273. Summary <ul><li>Enhance your script using TSL </li></ul><ul><ul><li>add logic (flow control, variables, operators) </li></ul></ul><ul><ul><li>insert testing functions using the Function Generator </li></ul></ul><ul><li>Add comment to your script for clarity </li></ul><ul><li>Use return values to check successful execution </li></ul><ul><li>Report checkpoint status information </li></ul><ul><li>Use debugging tools to check your test </li></ul>
    274. 274. LAB EXERCISE
    275. 275. <ul><li>Write a Script to get the user input through default dialog box. </li></ul><ul><li>Write a function to open Flight Reservation Sample Application. </li></ul><ul><li>Write a startup script for Loading GUI and invoking Application. </li></ul>

    ×