2. Benefits of Automated Testing WinRunner Testing Process WinRunner Recording Mode Working with other Test Suite Tools
3.
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
25. How Does WinRunner Identify an Object? John ******* WinRunner uses an object’s physical attributes to identify the object Displayed label class MSW_class x y abs_x abs_y maximizable focused width height active MSW_id handle minimizable nchildren enabled TOOLKIT_class ATTRIBUTES
26. How Does WinRunner Uniquely Identify an Object? John ******* WR uses the minimum number of static attributes to achieve unique identification label class Class: push_button Label: “OK”
27. How Does WinRunner Assign Object Names? John ******* WinRunner assigns a short name to each object called the logical name Class: push_button Label: “OK” button_press (“ OK ”); edit_set (“ Name ”, “John”); edit_set (“ Password ”, “mercury”);
28. Into Which Field Will WinRunner Play Back? set_window("Login", 10); edit_set ("Name:", "John"); John ? ?
29. Scope of Identification edit_set ("Name:", "John"); John WinRunner identifies an object within the scope of its parent window (not the entire application) set_window ("Login", 10);
30.
31.
32.
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("Automobile Purchase Form", 10); edit_set ("Address","234 Willow Drive"); edit_set ("Customer Name", "Thomas Paine"); Logical Name Physical Description
37. Techniques For Managing GUI Map Files Technique 1 One GUI Map file per test Technique 2 One GUI Map file for many tests
38. Object and Window Properties During Recording Name: Description: Date class: edit attached_text: "Date" set_window("Automobile Purchase Form", 10); list_select_item ("Make", "BMW"); edit_set ("Year", "1973"); edit_set("Model", "2002tii"); WINDOW: Automobile Purchase Form Year class: edit attached_text: "Year" Make class: list attached_text: "Make" Model class: edit attached_text: "Model" edit_set ("Date", "12/12/03"); WinRunner stores the names and descriptions for windows and objects in a temporary GUI Map file Temporary GUI Map file Technique 1
39. What Happens to These Properties? Use the GUI Map Editor to save the contents of the Temporary GUI Map file to a permanent GUI Map file Technique 1 Temporary GUI Map file Name: Description: Date class: edit attached_text: "Date" WINDOW: Automobile Purchase Form Year class: edit attached_text: "Year" Make class: list attached_text: "Make" Model class: edit attached_text: "Model"
41. Adding New Windows and Objects to a GUI Map File Invoke the GUI Map Editor 1 Technique 1
42. Adding New Windows and Objects to a GUI Map File Technique 1 Invoke the GUI Map Editor 1 Press the Expand Button to display Temporary and Permanent GUI Map files 2
43. Adding New Windows and Objects to a GUI Map File Technique 1 Invoke the GUI Map Editor 1 Move contents of Temp to Permanent by pressing Move button 3 Press the Expand Button to display Temporary and Permanent GUI Map files 2
44. Adding New Windows and Objects to a GUI Map File Technique 1 Save changes to permanent GUI Map file 4 Invoke the GUI Map Editor 1 Press the Expand Button to display Temporary and permanent GUI Map files 2 Move contents of Temp to permanent by pressing Move button 3
48. Creating a Permanent GUI Map File The cursor changes to a pointing hand Technique 2 Invoke the GUI Map Editor 1 Click the Learn Button 2
49. Creating a Permanent GUI Map File The cursor changes to a pointing hand Technique 2 Invoke the GUI Map Editor 1 Click the Learn Button 2 Click on the Window to be learned 3
50. Creating a Permanent GUI Map File The cursor changes to a pointing hand WinRunner learns all objects in window Technique 2 Invoke the GUI Map Editor 1 Click the Learn Button 2 Click on the Window to be learned 3
51. Creating a Permanent GUI Map File The cursor changes to a pointing hand WinRunner learns all objects in window Technique 2 Invoke the GUI Map Editor 1 Click the Learn Button 2 Click on the Window to be learned 3 Repeat for all windows in the application 4
52. Modify Names for Script Readability These names are unreadable. To what objects do they refer ? Technique 2
53. Modify Names for Script Readability Technique 2 Highlight the object whose name you want to change 1
54. Modify Names for Script Readability Technique 2 Highlight the object whose name you want to change 1 Click the Modify Button 2
55. Modify Names for Script Readability Technique 2 Highlight the object whose name you want to change 1 Change the Logical Name of the object 3 Click the Modify Button 2 Click OK 4
56. Modify Names for Script Readability "Name:” appears in your test script during recording instead of "ThunderRTTextBox_0" 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
58. Which Technique Should You Use? Technique 1 Advantages 1. Each test has GUI Map file independence 2. There is no need for a GUI Map file administrator 3. The GUI Map file is very simple to create–record and save Preferred method if the application is not intended to change during renovation Technique 2 Advantages 1. Object and window names can be very readable in the test script 2. If an object or window description changes, you only have to modify one GUI Map file–all tests will play back properly Preferred method if the application might change during renovation
59. Importance of the GUI Map File ? set_window("Automobile Purchase Form", 10); edit_set ("Date", "12/12/03"); list_select_item ("Make", "BMW"); edit_set ("Year", "1973"); edit_set("Model", "2002tii"); edit_set ("Purchase Price", "20000.00"); What happens when playback is attempted, and the proper GUI Map file is not loaded? Automobile Purchase Form Date
64. Use the GUI Map Editor to Fix File *L1 Insert.gui L1 Insert.gui Active GUI file: N:Y2K_ProjectGUInsert.gui Invoke the GUI Map Editor 1 Edit the description 3 Save the file 4 Highlight field and press Modify 2
65. Fixing the GUI Map File 12/12 /03 set_window("Automobile Purchase Form", 10); edit_set ("Date", "12/12/03"); list_select_item ("Make", "BMW"); edit_set ("Year", "1973"); edit_set("Model", "2002tii"); BMW 1973 2002tii ! Success WinRunner can now successfully playback the script
66.
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
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 "Terms" button is automatically enabled.
74. Verifying the AUT - Manual Testing Step Step Description Expected Result William Frawley PASS ? 2 Enter your name The Terms button is enabled 1 Select File > New SOFTWARE REQUIREMENT SPECIFICATIONS 2.3.2 Creating a New Order Once the end user selects File > New and enters their name, the "Terms" button is automatically enabled.
75. Verifying the AUT - Manual Testing Step Step Description Expected Result 2 Enter your name The Terms button is enabled 1 Select File > New William Frawley PASS ? SOFTWARE REQUIREMENT SPECIFICATIONS 2.3.2 Creating a New Order Once the end user selects File > New and enters their name, the "Terms" button is automatically enabled.
76. Verifying the AUT - Automated Testing William Frawley ? set_window ("Automobile Purchase Form", 8); menu_select_item ("File;New Form"); edit_set ("Customer Name", "William Frawley"); SOFTWARE REQUIREMENT SPECIFICATIONS 2.3.2 Creating a New Order Once the end user selects File > New and enters their name, the "Terms" button is automatically enabled.
77. What Is WinRunner Verification? Definition: Verification is the process by which WinRunner reports whether expected results are actualized by the application.
78. How WinRunner Verifies WinRunner compares the actual result to the stored, expected result 3 WinRunner captures an actual result during playback 2 1 WinRunner or the tester stores an expected result with the recorded test script WinRunner reports the comparison outcome as PASS or FAIL 4
79. How Does a Checkpoint Work? 1 2 3 4 = X ? WinRunner WinRunner WinRunner WinRunner Pass Fail Test Report Expected AUT Actual Expected AUT Actual
80. Process to Create Verification Run the recorded test script to verify correct execution 3 Test the checkpoint to ensure that it works for PASS and FAIL conditions 2 1 Capture or create the expected result within the recorded test script The tester creates the expected result only for text verification NOTE
88. How Does GUI Checkpoints Work ? 1 2 3 4 = X ? WinRunner WinRunner WinRunner WinRunner Pass Fail Test Report Expected Actual Expected Actual AUT AUT
89. Process for GUI checkpoints Test the Checkpoint to ensure that it works for ‘Pass’ & ‘Fail’ conditions 3 Create GUI checkpoint 2 1 Determine the visual cue(s) Run the recorded Test Script to verify correct execution 4
93. Checkpoint differs depending on the object to be verified Win_check_info Window Obj_check_info Generic Object button_check_info Button(check,radio,push) list_check_info List Checkpoint function Type of Object
94. Process for GUI checkpoints Create GUI checkpoint 2 1 Determine the visual cue(s)
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
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.
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.
109. Test directory after GUI Checkpoint Testing Project Tests chklist List1.ckl exp Test2 gui1.chk Test1 Test2
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.
115.
116.
117.
118. How Does Database Checkpoint Work ? 1 2 3 4 = X ? WinRunner WinRunner WinRunner WinRunner Pass Fail Test Report Expected Actual Expected Actual AUT AUT
119. Process for Database Checkpoints Test the condition to ensure that it works for Pass and Fail conditions 3 Use Database Checkpoint wizard to implement the Database Checkpoint 2 1 Record User actions to create database transaction Run the recorded scripts 4
120. Process for Database Checkpoints 1 Record User actions to create database transaction
121. Record user actions to create a Database transaction edit_set ( "Name:" , "Preeti" ); button_press ( "Insert Order" ); Preeti set_window ( "Flight Reservation" , 7 ); edit_set ( "Date of Flight:" , "09/06/02" );
122. Process for Database Checkpoints Use Database Checkpoint wizard to implement the database checkpoint 2 1 Record User actions to create database transaction
123.
124.
125.
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.
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.
130. Test directory after Database Checkpoint Testing Project Tests chklist list1.cdl msqr1.sql exp Test2 dbvf1 Test1 Test2
135. How Does Bitmap Checkpoint Work ? 1 2 3 4 = X ? WinRunner WinRunner WinRunner WinRunner Pass Fail Test Report Expected Actual Expected Actual AUT AUT
136. Process for Bitmap Checkpoints Test the condition to ensure that it works for Pass and Fail conditions 3 Create a Bitmap Checkpoint in the recorded Test Script 2 1 Is Bitmap verification necessary If yes verify screen area or object/window? Run the recorded scripts Differences are reported in Test Results and the difference Bitmap is found 4
137. Process for Bitmap Checkpoints Create a Bitmap Checkpoint in the recorded Test Script 2 1 Is Bitmap verification necessary If yes verify screen area or object/window?
138.
139.
140.
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.
143.
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
149. Process for Text Checkpoints Insert code to compare the actual and expected value 3 Insert a function to read the actual text from the AUT during playback 2 1 Define a variable in the script and assign the expected value Insert code to report the comparison outcome to WinRunner Test Results window 4
150. Process for Text Checkpoints 1 Define a variable in the script and assign the expected value
151.
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.
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.
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
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.
165. Data Driving Tests Create a test 1 Modify test to read from Data Table 2 3 Move data to Data Table 1. Create test with data 2. Verify script is ready for data driving Create a test
166. 1. Create a Test Create Test with Data invoke_application(“flight1a.exe","","C:",SW_SHOW); set_window ("Login", 10); edit_set ("userid", "Josephine"); password_edit_set ("password", “kxpvnwoulxjuax” ); button_press ("OK"); set_window ("Flight Reservation", 10); win_check_gui("Flight Reservation", "list1.ckl", "gui1", 1); menu_select_item ("File;Exit"); Test Script
167. 1. Create a Test Verify that Script Is Ready to Data Drive invoke_application(“flight1a.exe","","C:",SW_SHOW); set_window ("Login", 10); edit_set ("userid", "Josephine"); password_edit_set ("password", “kxpvnwoulxjuax” ); button_press ("OK"); set_window ("Flight Reservation", 10); win_check_gui("Flight Reservation", "list1.ckl", "gui1", 1); menu_select_item ("File;Exit"); Does the script verify the expected results? Are all actions that involve inputting data recorded into the script? Are all synchronization points entered into the script? Are the initial and end conditions the same? ? Test Script
168. Data Driving Tests Create a test 1 Move data to Data Table 3 Modify test to read from Data Table 2 Modify test to read from Data Table 1. Run DataDriver Wizard
169. The DataDriver Wizard will convert your baseline script table = "default.xls" ; rc = ddt_open (table, DDT_MODE_READ); if (rc!= E_OK && rc != E_FILE_OPEN) pause ( "Cannot open table." ); 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 ( "D:flight1a.exe" , "" , "" ,SW_SHOW); set_window ( "Login" , 10 ); edit_set ( "Agent Name:" , ddt_val (table, "Agent_Name" )); password_edit_set ( "Password:" , ddt_val (table, "Password" )); button_press ( "OK" ); set_window ( "Flight Reservation" , 22 ); menu_select_item ( "File;Exit" ); } 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 ( "D:flight1a.exe" , "" , "" ,SW_SHOW); set_window ( "Login" , 10 ); edit_set ( "Agent Name:" , "Catherine" ); password_edit_set ( "Password:" , "kzptnyoslzjsaz" ); button_press ( "OK" ); set_window ( "Flight Reservation" , 22 ); menu_select_item ( "File;Exit" );
170. Open the Data Table and check that it was successfully opened 1 table = "default.xls" ; rc = ddt_open (table, DDT_MODE_READ); if (rc!= E_OK && rc != E_FILE_OPEN) pause ( "Cannot open table." ); 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 ( "D:flight1a.exe" , "" , "" ,SW_SHOW); set_window ( "Login" , 10 ); edit_set ( "Agent Name:" , ddt_val (table, "Agent_Name" )); password_edit_set ( "Password:" , ddt_val (table, "Password" )); button_press ( "OK" ); set_window ( "Flight Reservation" , 22 ); menu_select_item ( "File;Exit" ); } ddt_close (table); The DataDriver Wizard will convert your baseline script so that it will: 2. Modify Test to Read from Data Table What Does the DataDriver Do? Add a loop to read through all your data rows 2
171. table = "default.xls" ; rc = ddt_open (table, DDT_MODE_READ); if (rc!= E_OK && rc != E_FILE_OPEN) pause ( "Cannot open table." ); 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 ( "D:flight1a.exe" , "" , "" ,SW_SHOW); set_window ( "Login" , 10 ); edit_set ( "Agent Name:" , ddt_val (table, "Agent_Name" )); password_edit_set ( "Password:" , ddt_val (table, "Password" )); button_press ( "OK" ); set_window ( "Flight Reservation" , 22 ); menu_select_item ( "File;Exit" ); } ddt_close (table); Open the Data Table and check that it was successfully opened 1 The DataDriver Wizard will convert your baseline script so that it will: 2. Modify Test to Read from Data Table What Does the DataDriver Do? Add a loop to read through all your data rows 2 Parameterize data values so that it reads from the Data Table 3
172. 2. Modify Test to Read from Data Table What Does the DataDriver Do? table = "default.xls" ; rc = ddt_open (table, DDT_MODE_READ); if (rc!= E_OK && rc != E_FILE_OPEN) pause ( "Cannot open table." ); 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 ( "D:flight1a.exe" , "" , "" ,SW_SHOW); set_window ( "Login" , 10 ); edit_set ( "Agent Name:" , ddt_val (table, "Agent_Name" )); password_edit_set ( "Password:" , ddt_val (table, "Password" )); button_press ( "OK" ); set_window ( "Flight Reservation" , 22 ); menu_select_item ( "File;Exit" ); } ddt_close (table); Open the Data Table and check that it was successfully opened 1 The DataDriver Wizard will convert your baseline script so that it will: Add a loop to read through all your data rows 2 Parameterize data values so that it reads from the Data Table 3 Close the Data Table 4
173. 2. Modify Test to Read from Data Table Running the DataDriver Wizard invoke_application(“flight1a.exe","","C:",SW_SHOW); set_window ("Login", 10); edit_set ("userid", ”Catherine"); password_edit_set ("password", “kxpvnwoulxjuax” ); button_press ("OK"); set_window ("Flight Reservation", 10); win_check_gui("Flight Reservation", "list1.ckl", "gui1", 1); menu_select_item ("File;Exit"); 1. Highlight area you want to be data driven. 2. Start the DataDriver Wizard. invoke_application(“flight1a.exe","","C:",SW_SHOW); set_window ("Login", 10); edit_set ("userid", ”Catherine"); password_edit_set ("password", “kxpvnwoulxjuax” ); button_press ("OK"); set_window ("Flight Reservation", 10); win_check_gui("Flight Reservation", "list1.ckl", "gui1", 1); menu_select_item ("File;Exit"); 1 2
174. 2. Modify Test to Read from Data Table Running the DataDriver Wizard Final Result table = " default.xls "; rc = ddt_open( table , DDT_MODE_READ); if (rc!= E_OK && rc != E_FILE_OPEN) pause("Cannot open table."); 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("D:flight1a.exe","","",SW_SHOW); set_window ("Login", 10); edit_set ("Agent Name:",ddt_val( table ,"Agent_Name")); password_edit_set("Password:",ddt_val( table ,"Password")); button_press ("OK"); set_window ("Flight Reservation", 22); menu_select_item ("File;Exit"); } ddt_close( table );
175. 2. Modify Test to Read from Data Table Running the DataDriver Wizard Where does the Data Table reside? <test name> default.xls
176.
177. 3. Move Data to Data Table Importing Data From Database to Data Table Database
178. 3. Move Data to Data Table Importing Data From Database to Data Table Database
179. 2. Modify Test to Read from Data Table Running the DataDriver Wizard edit_set ("Agent Name:", “Catherine”); ? Final Result edit_set(“Agent Name:”, ddt_val(table,”Agent_Name”) );
180. 2. Modify Test to Read from Data Table Running the DataDriver Wizard
181. Data Driving Tests Create a test 1 2 3 Move data to Data Table Modify test to read from Data Table
182.
183. 3. Move Data to Data Table Insert Data Manually Open the Data Table 1 Enter Data you want to test 2 Close Data Table and save script 3
184. 3. Move Data to Data Table Add Data Dynamically During Run Create Invoice Test 1 mer InvoiceNum 3421 yelet phine Data Table 3423 3423 3423 . . . . . . ddt_set_val(... Update Invoice Test 2 . . . . . . edit_set(...,ddt_val ...
185. 3. Move Data to Data Table Add Data Dynamically During Run Add column to Data Table for data to be added 1
186. 3. Move Data to Data Table Add Data Dynamically During Run table = "default.xls"; rc = ddt_open(table, DDT_MODE_READ); if (rc!= E_OK && rc != E_FILE_OPEN) pause("Cannot open table."); 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 ("Automobile Purchase Form", 2); edit_set ("Customer Name",ddt_val(table,"Customer_Name")); edit_set("Address:",ddt_val(table,"Address")); edit_set ("License",ddt_val(table,"License")); obj_mouse_click ("Method of Payment", 23, 13, LEFT); button_set (ddt_val(table,"Cash"), ON); list_select_item ("Make",ddt_val(table,"Make")); # Item Number 0; edit_set ("Model",ddt_val(table,"Model")); button_press ("Insert Sale"); edit_wait_info("StatusBar","value","New Purchase Completed Successfully...",10); } ddt_close(table); Add column to Data Table for data to be added 1 ddt_set_val ( table , “ ”, InvoiceNumber ); obj_get_info ("Invoice No:","label", 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
191. How Do Client-Server Applications Behave? Single User Database server Server response time:
192. How Do Client-Server Applications Behave? Several Users Database server Server response time:
193. How Do Client-Server Applications Behave? Many Users Database server Server response time:
194. How Do Client-Server Applications Behave? Example Response Times RESPONSE TIME Several users 0.61 Many users 1.00 Single user 0.33
195. Complete the Business Process Manually Database 07/07/01 Los Angeles Denver Cash Enter 07/07/01 on Date field Select LA from Fly From field Select Denver from Fly To field Enter Cash as Method of Payment Press Flights button Example steps
196. Complete the Business Process Manually Database Enter 07/07/01 on Date field Select LA from Fly From field Select Denver from Fly To field Enter Cash as Method of Payment Press Flights button Select a flight Example steps
197. Complete the Business Process Manually Database 07/07/01 Los Angeles Denver Cash Errol Flynn Enter Customer Name Insert Order Wait for response before continuing Enter 07/07/01 on Date field Select LA from Fly From field Select Denver from Fly To field Enter Cash as Method of Payment Press Flights button Select a flight 7328 Close application Example steps
198. Manual Steps Recorded in the Test Script edit_set ("Date","070701"); list_select_item ( "Fly From:", "Los Angeles" ); list_select_item ("Fly To:", "Denver"); list_select_item ("Payment:", "Cash" ); button_press ( "Flights" ); button_press ( "Insert Order" ); ??? 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 ( "Flight Reservation" ); Close the application set_window ( "Flights Table" , 4); button_press ( "OK" ); Example steps edit_set ( "Customer Name:" , "Errol Flynn" ); set_window ( "Flight Reservation" , 10);
199. Why Not Insert a Wait Statement? button_press ( "Insert Order" ); win_close ( "Flight Reservation" ); wait ( ); 10 50 users 5.1 seconds 500 users 9.5 seconds 1 user 3.7 seconds AVERAGE RESPONSE TIMES
200. Why Not Insert a Wait Statement? AUT 11.3 seconds RUN #1 Wait (10); button_press ( "Insert Order" ); win_close ( "Flight Reservation" ); wait ( ); 10 button_press ( "Insert Order" ); win_close ( "Flight Reservation" ); wait ( ); 15 PROBLEM: Test run failed because wait didn't last long enough SOLUTION: Add 50% to wait time as safety cushion
201. Why Not Insert a Wait Statement? AUT 5.5 seconds RUN #2 Wait (15); 15 seconds button_press ( "Insert Order" ); win_close ( "Flight Reservation" ); 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 ( "Insert Order" ); win_close ( "Flight Reservation" ); ???
202. What Is a Synchronization Point? A synchronization point is a line in the test script that instructs WinRunner to wait for a certain response from the application during playback, just as a real user would. Definition:
203. ADD SYNCHRONIZATION POINTS Introduction to Synchronization Add Synchronization Points Record user actions in script 1 Synchronize script to application under test 2 Add verification statements to check AUT 3 Run test or suite of tests 4
204. Process to Add Synchronization Points Add Synchronization Points Establish visual cues to synchronize 1 Determine type of synchronization point 2 Add synchronization point to test script 3 Play back revised script 4
205. Establish Visual Cue to Synchronize Examples 1 Wait for a bitmap to refresh BITMAP Wait for a window WINDOW Wait for an object state OBJECT STATE
206. Methods of Synchronization obj_wait_info ("Bar","label", "Insert Done...", 20); Wait for an object state/property value obj_wait_bitmap ("Window", "Img1", 10, 209, 170, 81, 20 ); Wait for a bitmap set_window ("Flight Reservation", 20); Wait for a window
207. Determine Type of Synchronization (Waiting for a Window) 2 Window name Time set_window ("Flight Reservation", 20); Wait for main window to appear after login
208. Properties of Standard GUI Objects (Examples) Boolean Values 0 = False 1 = True State 3 State 2 State 1 class: push_button, focused: 1, label: "Insert Order", enabled: 1 class: push_button, focused: 0, label: "Insert Order", enabled: 1 class: push_button, focused: 0, label: "Insert Order", enabled: 0
211. Determine Type of Synchronization (Change in Object Property/State) 2 obj_wait_info ("Bar","label", "Insert Done...", 20); Object name Object property Synchronize with a progress bar message
212. Determine Type of Synchronization (Change in Object Property/State) 2 obj_wait_info ("Bar","label", "Insert Done...", 20); value Time Synchronize with a progress bar message
213. Determine Type of Synchronization (Waiting for a Bitmap) 2 obj_wait_bitmap ("Window", "Img1", 10, 209, 170, 81, 20 ); Object name Bitmap name Sync with browser loading a bitmap
214. Determine Type of Synchronization (Waiting for a Bitmap) 2 obj_wait_bitmap ("Window", "Img1", 10, 209, 170, 81, 20 ); Time x , y Sync with browser loading a bitmap
215. Determine Type of Synchronization (Waiting for a Bitmap) 2 obj_wait_bitmap ("Window", "Img1", 10, 209, 170, 81, 20 ); width height Img1.bmp Bitmap File Location: Test_name exp Test_name Sync with browser loading a bitmap
216. How Long Does It Wait? "OK" "Error" TIME PARAMETER Global timeout setting Global timeout interval GLOBAL + Test run 1 TOTAL = Maximum total timeout Synchronization statement timeout parameter Script continues Script continues Test run 2
217. Add Synchronization to Test Script Wait for a Window 3 # Login set_window ( "Login" ,4); edit_set ( "Agent Name:", "mercury" ); password_edit_set ( "Password:","kjzisllz" ); button_press ( "OK" ); # Flight Reservation set_window ( "Flight Reservation" , 25 ); Locate the TSL statement that points to the determined visual cue 1
218. Add Synchronization to Test Script Wait for a Window # Login set_window ( "Login" ,4); edit_set ( "Agent Name:", "mercury" ); password_edit_set ( "Password:","kjzisllz" ); button_press ( "OK" ); # Flight Reservation set_window ( "Flight Reservation" , 25 ); 3 Recorded time parameter reflects delay during script recording session 60 Locate the TSL statement that points to the determined visual cue 1 Modify timeout parameter to allow ample time for window to appear 2
219. Add Synchronization to Test Script Wait for an Object State/Property Value list_select_item ( "Fly From:","Denver" ); list_select_item ( "Fly To:","San Francisco" ); # Flights Table set_window ( "Flights Table" ,2); list_activate_item ( "Flight", "2452..." ); # Flight Reservation set_window ( "Flight Reservation" ,3); edit_set ( "Customer Name:","Bob Smith" ); button_press ( "Insert Order" ); 3 Locate the line in the script to insert the synchronization point 1
220. Add Synchronization to Test Script Wait for an Object State/Property Value list_select_item ( "Fly From:","Denver" ); list_select_item ( "Fly To:","San Francisco" ); # Flights Table set_window ( "Flights Table" ,2); list_activate_item ( "Flight", "2452..." ); # Flight Reservation set_window ( "Flight Reservation" ,3); edit_set ( "Customer Name:","Bob Smith" ); button_press ( "Insert Order" ); 3 Locate the line in the script to insert the synchronization point 1 Select Create > Synchronization Point/For Object/Window Property 2
221. Add Synchronization to Test Script Wait for an Object State/Property Value list_select_item ( "Fly From:","Denver" ); list_select_item ( "Fly To:","San Francisco" ); # Flights Table set_window ( "Flights Table" ,2); list_activate_item ( "Flight", "2452..." ); # Flight Reservation set_window ( "Flight Reservation" ,3); edit_set ( "Customer Name:","Bob Smith" ); button_press ( "Insert Order" ); 3 Using the Hand pointer, click on the object to synchronize 3 Locate the line in the script to insert the synchronization point 1 Select Create > Synchronization Point/For Object/Window Property 2
222. Add Synchronization to Test Script Wait for an Object State/Property Value list_select_item ( "Fly From:","Denver" ); list_select_item ( "Fly To:","San Francisco" ); # Flights Table set_window ( "Flights Table" ,2); list_activate_item ( "Flight", "2452..." ); # Flight Reservation set_window ( "Flight Reservation" ,3); edit_set ( "Customer Name:","Bob Smith" ); button_press ( "Insert Order" ); 3 "Progress Bar" Select the object attribute that will contain the value of the visual cue 4 Using the Hand pointer, click on the object to synchronize 3 Locate the line in the script to insert the synchronization point 1 Select Create > Synchronization Point/For Object/Window Property 2
223. Add Synchronization to Test Script Wait for an Object State/Property Value list_select_item ( "Fly From:","Denver" ); list_select_item ( "Fly To:","San Francisco" ); # Flights Table set_window ( "Flights Table" ,2); list_activate_item ( "Flight", "2452..." ); # Flight Reservation set_window ( "Flight Reservation" ,3); edit_set ( "Customer Name:","Bob Smith" ); button_press ( "Insert Order" ); 3 obj_wait_info ( "Progress Bar" , "label" , "Insert Done…”, 10); "Progress Bar" Click the Paste button in Wait for object window 5 Select the object attribute that will contain the value of the visual cue 4 Using the Hand pointer, click on the object to synchronize 3 Locate the line in the script to insert the synchronization point 1 Select Create > Synchronization Point/For Object/Window Property 2
224. Add Synchronization to Test Script Wait for a Bitmap Area 3 # Mercury Homepage set_window ( "Mercury Homepage" , 5 ); edit_set ( "Address", "http://www.merc-int.com” ); obj_mouse_click ( "mpage", "Img2" , 471, 328 ); Locate the line in the script to insert the synchronization point 1
225. Add Synchronization to Test Script Wait for a Bitmap Area # Mercury Homepage set_window ( "Mercury Homepage" , 5 ); edit_set ( "Address", "http://www.merc-int.com” ); obj_mouse_click ( "mpage", "Img2" , 471, 328 ); 3 Select Create > Synchronization Point > For Screen Area Bitmap 2 Locate the line in the script to insert the synchronization point 1
226. Add Synchronization to Test Script Wait for a Bitmap Area 3 # Mercury Homepage set_window ( "Mercury Homepage" , 5 ); edit_set ( "Address", "http://www.merc-int.com” ); obj_mouse_click ( "mpage", "Img2" , 471, 328 ); Click left mouse button and drag pointer to select area; press right button to complete selection 3 Select Create > Synchronization Point > For Screen Area Bitmap 2 Locate the line in the script to insert the synchronization point 1
227. Add Synchronization to Test Script Wait for a Bitmap Area 3 # Mercury Homepage set_window ( "Mercury Homepage" , 5 ); edit_set ( "Address", "http://www.merc-int.com” ); obj_wait_bitmap ( "mpage","Img2" ,6,7,8,101,114); obj_mouse_click ( "mpage", "Img2" , 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
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:testsguifiles”; public const AUT_PATH = “c:appbin”; public const E_MY_ERROR_CODE = -12345; # Variable declarations static lineCounter ; public flightVersion = “Flight1a.exe”; Test Script 1 Examples GUI_load ( GUI_FILE_PATH & “myFile.gui”); invoke_application ( AUT_PATH & flightVersion , ““, AUT_PATH , SW_SHOW); ... rc = my_function (); if (rc == E_MY_ERROR_CODE ) ... Test Script 2
240. Variables and Constants Strings and Numbers number1 = "4" ; number2 = 3 ; value = number1 * number2; value contains 12 cost = "10 Dollars" ; amount = “The price is “ & cost + 5 ; amount contains “The price is 15” value_a = "3.3" ; value_b = "2,5" ; 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!
245. Arrays Multi-dimensional Arrays flightinfo[ 1 , "Date” ] = "07/22/99" ; flightinfo[ 1 , "FlyFrom” ] = "Los Angeles" ; flightinfo[ 1 , "FlyTo” ] = "Denver" ; flightinfo[ 1 , "Flight No” ] = "4300" ; flightinfo[ 2 , "Flight No” ] = "1234" ; flightinfo[ 3 , "Flight No” ] = "9999" ; 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.
247. Flow Control Conditional Decision Making set_window (“Flight Reservation”); obj_get_info (“Order No:”, “value”, OrderNo); if ( OrderNo == “ ” ) report_msg (“No order number.”); else button_press (“Update Order”); set_window (“Flight Reservation”); obj_get_info (“Order No:”, “value”, OrderNo); if ( OrderNo == “ ” ) { report_msg (“No order number.”); } else { button_press (“Update Order”); } win_get_text(”Flight Info”, version, 42, 68, 159, 89); if ( version != “Version 1.0” ) { report_msg (“Wrong Version!”); texit; } Example 2 Best practice: always set curly brackets Example 1
248. Flow Control switch Statement set_window ("Fax Order"); edit_get_text ("Class:", class); switch (class) { case "Economy": result = PASS; message="Correct class: Economy"; break; case "Business": result = FAIL; message="Wrong class: Business"; break; case "First": result = FAIL; message="Wrong class: First"; break; } tl_step (“Class of Service”, result, message); Example
249. Flow Control for Loop # Looping for stress testing for (i=0; i<1000; i++) { set_window (“Flight Reservation”); menu_select_item ("File;Fax Order..."); set_window ("Fax Order"); edit_set ("Fax Number:", “4085551212”); button_press (”Send"); set_window (“Flight Reservation”); obj_wait_info (“StatusBar”, “label”, “Fax Sent”, 50); } Example
250. Flow Control while Loop file= "c:dataflight_orders.txt"; 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( "Opened Order " & ord_num ); } file_close( file ); The statements in this while loop will not be executed if the condition is not TRUE (if the file cannot be opened) Example
251. Flow Control do while Loop # Flight Reservation set_window ( "Flight Reservation", 2 ); edit_set ( "Name:", "" ); new_len=0; do { old_len= new_len; edit_type( "Name:", "123" ); edit_get_info( "Name:", "value", value ); new_len= length( value ); } while( old_len < new_len ); report_msg( "Max Name length ” & new_len & " characters" ); The statements in this while loop are executed at least once. Example
252.
253. Operators Arithmetic/Relational edit_get_text ("Tickets", tickets); edit_get_text ("Price", price); edit_get_text ("Total", total); if ( tickets * price == total ) tl_step (“Total”, PASS, “Correct Total”); else { tl_step (“Total”, FAIL, "Wrong Total"); report_msg(“Expected Value: ” & tickets * price); report_msg(“Actual Value: ” & total ); } Best Practice: For complicated calculations, check values in the AUT against pre-calculated values in a data table or data file Example
254. Operators Logical Operators # Value is greater than 50 AND less than 100 if ( value > 50 && value <100 ) tl_step (“Value tested”, PASS, “Correct Value”); Logical AND # Value equals Saturday OR value equals Sunday if ( value== “Saturday” || value== “Sunday” ) tl_step (“Value tested”, PASS, “ it’s Weekend !”); Logical OR # Value is equal to or greater than 1 AND less than or equal to 10 # AND value IS NOT 5 if ( value >=1 && value <=10 && value != 5 ) tl_step (“Value tested ”, PASS, “is between 1-10 and not 5”); Combination
255.
256.
257.
258.
259.
260.
261.
262.
263.
264.
265.
266.
267.
268.
269.
270.
271.
272. Creating a Startup Script ############################################ # TestSuite Training Init Test # ############################################ # Loading the prepared GUI file GUI_load ( getvar ( "testname" )& "flight60.gui" ); # Configure the MS Mask object to map to edit objec # Data of Flight recording depends on this set_class_map ( "MSMaskWndClass" , "edit" ); set_record_attr ( "MSMaskWndClass" , "class attached_t set_record_method ( "MSMaskWndClass" , RM_RECORD); # Configure the status bar in the GUI Map set_class_map ( "AfxWnd40" , "object" ); set_record_attr ( "AfxWnd40" , "class regexp_MSW_class S:estProjectnitScript 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