QARun Exercise Guide
Transcription
QARun Exercise Guide
QARun Exercise Guide Release 4.6 Please direct questions about QARun_ or comments on this document to: QARun Technical Support Compuware Corporation 31440 Northwestern Highway Farmington Hills, MI 48334-2564 1-800-538-7822 Outside the USA and Canada, please contact your local Compuware office or agent. Copyright © 1999 Compuware Corporation. All rights reserved. Unpublished rights reserved under the Copyright Laws of the United States. U.S. GOVERNMENT RIGHTS: Use, duplication, or disclosure by the U.S. Government is subject to restrictions as set forth in Compuware Corporation license agreement and as provided in DFARS 227.7202-1(a) and 227.7202-3(a) (1995), DFARS 252.227-7013(c)(1)(ii)(OCT 1988), FAR 12.212(a) (1995), FAR 52.227-19, or FAR 52.227-14 (ALT III), as applicable. Compuware Corporation. THIS MATERIAL CONTAINS CONFIDENTIAL INFORMATION AND TRADE SECRETS OF COMPUWARE CORPORATION. USE, DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF COMPUWARE CORPORATION. Compuware, QARun, QADirector, TrackRecord, QAHiperstation+ and QAHiperstation are trademarks or registered trademarks of Compuware Corporation. All other company or product names are trademarks of their respective owners. Doc. CWQART1.0A December 17, 1999 Contents: Exercise 1: Loading QARun and Logging On............................................................................ 5 Exercise 2: Learning a Script Using Notepad............................................................................. 9 Exercise 3: Testing the Effects of Pause Mode......................................................................... 13 Exercise 4A: Window, Form, List Box and Menu Checks........................................................ 19 Exercise 5A: Bitmap and Text Checks..................................................................................... 29 Exercise 5B: BitMap and Text Checks...................................................................................... 39 Exercise 6A: Timing Checks .................................................................................................... 47 Exercise 6B: Timing Checks .................................................................................................... 51 Exercise 7A: Automating a Host............................................................................................... 55 Exercise 7B: Automating a Host............................................................................................... 63 Exercise 8: Creating Image Map Entries .................................................................................. 67 Exercise 9A: Setting the Editor Environment........................................................................... 73 Exercise 9B: Setting the Editor Environment ........................................................................... 79 Exercise 10A: Creating Object Map Entries............................................................................. 81 Exercise 12A: Creating Driver Scripts ...................................................................................... 85 Exercise 12B: Creating Driver Scripts ...................................................................................... 87 Exercise 13A: Modularizing Scripts Using Functions ............................................................... 89 Exercise 13B: Modularising Scripts Using Functions................................................................ 93 Exercise 14A: Adding cars to the QADemo database................................................................ 95 Exercise 14B: Creating an Account on the Host........................................................................ 99 Exercise 15A: Data Input using a Test Data File..................................................................... 103 Exercise 15B: Data Input using a Test Data File ..................................................................... 111 Exercise 16A: Testing for Valid and Invalid Data Input .......................................................... 113 Exercise 16B: Testing for Valid and Invalid Data Input .......................................................... 119 Exercise 17A: Capturing Data From QADemo ....................................................................... 121 Exercise 17B: Capturing Data From Testbed .......................................................................... 125 Exercise 17C: Synchronizing using Autowait capabilities ....................................................... 129 Exercise 18: Using PromptBox(), MessageBOX() & TextPanel()........................................... 133 Exercise 19A: Creating a Dialog Box ..................................................................................... 139 Exercise 19B: Creating a Dialog Box...................................................................................... 147 Exercise 20A: Date Aging ...................................................................................................... 155 3 Exercise 1: Loading QARun and Logging On Objective - How to Start QARun - Browse predefined objects - The Toolbar, Module Bar and Status bar can be displayed by using the view menu - To Start QARun, a valid User ID and Password are needed - Lists of script components can be displayed in windows - Each of window has a unique associated menu - Windows can be displayed using menu or tool bar options Notes: - None Instructions Step Action Use Window’s start button to select the QARun program option… Start/Programs/Compuware/QARun/QARun. Screen QARun Wait for the QARun Log On dialog to appear. Select Admin as the User Name. Type admin as the password. Press the OK button. Wait for the QARun main window to appear. Notice which menu options are available when no child windows are open. 5 1. Select File/Browse, the Browse dialog is displayed. Select Scripts from the Browse list and press OK. 2. Browse Scripts screen will be displayed. There are no scripts to display presently. Notice the menu options have changed. These menu options are specific to the Browse Scripts window. 3. Select File/Browse, the Browse dialog is displayed. Select Checks from the Browse list and press OK 4. Browse Checks screen will be displayed. Presently there are no checks to display. Notice the menu options have changed again. As with the Browse Scripts window, these menu options are specific to the Browse Checks window. Remember, in order to use a desired menu option the window to which the menu is associated must be open. 6 5. Select View and alter the main window by putting a check mark next to: Tool Bar Module Bar Status Bar. The check mark selects each option. 6. Notice the options available on the Module Bar. The third and fourth buttons on the module bar can be used in place of the File/Browse window to select the Browse Scripts and Browse Checks windows ( respectively ). Browse Scripts Module Bar Button Browse Checks Module Bar Button 7. Close all the Browse windows using the system close button in the upper right corner of each window. Points Learned Starting QARun Logging in to QARun with a user id and password Browsing QARun Script components Menu options change to match the functionality associated with each child window Selecting which tool bar and status bar options to view 7 Exercise 2: Learning a Script Using Notepad Objective - To learn the process of starting Windows NOTEPAD and returning to Program Manager - Learn application interaction - Read the learned script - Use hot keys to start and stop learning a script. - Run a script Notes: - Notice that the short cut keys used inside the QARun Editor include the Control key. The short cut keys used while QARun is learning or running start with the Alt key. Short cut keys {Control L} {Control R} Starts learning {Alt {F10}} Runs the script {Alt {F12}} Stops or Starts learning Stops a Running Script Instructions Step 1. Action Start a New Script by selecting Menu Option File/New or by clicking the New Icon. 2. Select Script and click OK. Screen 9 3. Click the Red Learn Button, Type {Control L} or Select Menu Option Options/Learn Script to put QARun into “Learn” mode. 4. From the Start Button select Run. 5. Type in NOTEPAD.EXE. Click on the OK Button. 6. Maximize the NOTEPAD window. Type in your name. 10 7. Select File/Exit. The “Do you want to save changes?” window will appear. Select No. Stop learning by using {Alt {F10}}. 8. Run the script by performing one of the following actions: Clicking the Blue Run Button, Typing {Control R} or Selecting Menu Option Run/Run Script. 9. Name the script EX02. Add a description for the script. This description appears in the Browse Scripts window to allow easy identification of the script. Adding a Comment to the script concerning any design or future maintenance issues will help in the long term use of the script. 10. Press the OK Button. The Run Script dialog is displayed. Select Default from the drop down list. Press OK. 11 11. The script will execute exactly as learned and upon completion the script is displayed. Read through the script and identify how each interaction with the notepad application was recorded in the script. Points Learned Recording keystrokes Attaching to a Windows application Saving and running scripts 12 Exercise 3: Testing the Effects of Pause Mode Objective - To increase the speed of a previously learned script To interrogate the log report Use the Command wizard Show how the Run environment variables can be used to change the way a script is executed - How to change the run environment variables programmatically Notes: - Under Options/Configure/Replay ensure Auto Load Log is checked Instructions Step Action 1. Load EX02 into the script editor. Select File|Save As to save the script as EX03. Run script EX03. 2. At the Run Script dialog select the “Default” environment and click on the Edit button. 3. Create new run environment by pressing the Add button. Screen 4. Name the new environment Filter. Copy settings from Default. Press OK. 5. Click on the Filter Environment. Change the Test Run setting to TSTRUN. This defines the name of the output log file generated by executing the script in this run environment. 6. Click on the Replay tab and deselect Pause Mode. Press the OK Button. 7. Set the Run environment to Filter in the Run Script dialog box. Press the OK button. NOTE: The script will start executing. Notice how much faster the script is executing. 14 8. When the script has stopped, view the log that was generated. Close the Log View. 9. Return to the script and position the cursor above the first "Attach" statement. 10. Click on the toolbar button for the command wizard. The Command Wizard window will appear. 11. Select Synchronization from the Command Groups section. NOTE: This will display the subset of the commands associated with the synchronization of scripts. 12. Look for the command … Replay.PauseMode in the commands list window. Press the Next Button. 15 13. Select 0 ( default ) so the pause statements will be ignored by QARun during the execution of the script. Press the Next Button. 14. The box titled “The text which will be pasted in the editor.” displays the command as it will be inserted into the script. Press the Paste button. 15. Note the command that was pasted into the script. 16. From the QARun menu, select Run|Run Script. Press the “Edit” button to Edit the runtime environment, turning Pause Mode ON(checked) in Replay settings. Press OK. 16 17. Press OK in the Run Script dialog box with the environment set to Filter. 18. View the log that is generated. Note the TSTRUN is displayed in the test run column. Points Learned Effect of Replay.PauseMode Viewing Logs 17 Exercise 4A: Window, Form, List Box and Menu Checks Objective - Perform some high level checks against QADemo - Use the Filter functionality of the log file - Additional knowledge of what is being logged Notes: - None Instructions Step Action 1. Create a new script (using the New Button or File|New) and select Script. 2. Switch Learn ON using {Control L } or select the Record button. 3. Learn the process of starting version 1 of QADemo by selecting the following Start menu option … “Start\Programs\ Compuware\QARun\QADemo Version 1” 4. When QADemo appears sign on using the userid DTL and the password as PASS. Click on a Location Radio Button. Press OK. Screen 5. Use {Alt {F8}} to insert the following check. QARun pauses the Learning process to insert a check. Create a Window Check against the popup window titled “New” in QADemo. When the Browse Checks window pops up, press New. 6. Select a Window Check and press OK. 7. Give the check a logical Name. 8. Press the Identify button, then place the cross hairs on the Title bar of the popup window titled “New” . Click the left mouse button. 20 9. Review the learned settings. Press the OK button. NOTE: QARun will return to the Learn mode. 10. Press {Alt {F8}} to create a Menu check against the QADemo main window. When the Browse Checks window pops up, press New. 11. Select a Menu Check and press OK. 21 12. Give the check a name based on a logical naming convention. 13. Press the Identify button, then place the cross hairs on the title bar of the QADemo Main Window. Click the left mouse button. NOTE: QARun will prompt you to select the menu to be checked and ask you to press {Control-Insert}. With the cursor positioned on the main menu, press the control and insert keys at the same time. 14. Review the Captured Values. Press the OK Button. 15. 22 The New popup window will appear. 16. Use {Alt {F8}} to create a Form Check against the popup window titled “New”. When the Browse Checks window pops up, press New. 17. Select Form Check and press OK. 18. Give the check a logical Name. 19. Press the Identify button, then place the cross hairs on the title bar of the popup window titled “New”. Click the left mouse button. 23 20. Press the OK Button. NOTE: QARun will return to learn mode. 21. Use {Alt {F8}} to Create a List Check against the “New” popup window. When the Browse Checks window pops up, press New. 22. 24 Select a List Check and press OK. 23. Give the check a logical Name. 24. Press the Identify button, then place the cross hairs on the listbox in the “New” popup window. Click the left button. 25. Press the OK Button. NOTE: QARun will return to the learn mode. 26. Select the Cancel button on the New dialog. 25 27. Close down QADemo by selecting File|Exit from the menu. 28. Switch learning OFF using {Alt {F10}}. 29. Run the script saving it as EX04A. Press OK. Use the run environment named FILTER, edit the run environment with Pause Mode not selected (no check). Press OK. 30. 31. The Log View is displayed when the script completes execution. If not, with the browse scripts window open and a script open in the editor, use the options|configure|replay property sheet to select the auto load log option. Press the Select Filter button then press the Add button. Enter the name “Checks and Comments” to use for the new filter. Press the OK Button. 26 32. When the select filter window reappears, select the filter created in step 31. Press the Edit button. 33. Deselect the System and Commands Checkboxes. Press the OK Button. 34. Press Checks tab to select types of check to be displayed in the log. Select only the following checks: Form, Menu, and Window The list check defined earlier will not be shown in the log when this filter is used. 27 35. Press the OK Button. 36 Modify the script so that it executes version three of QADemo. 37 Run the modified script and view the log that is generated. Filter out all but passed and failed checks. Did the menu check fail again? Why? Points Learned Creating Window, Menu, Form and List checks Creating checks while learning a script Viewing log files and filtering 28 Attach "PopupWindow~1" Button "Start", 'Left SingleClick' PopupMenuSelect "Programs~Compuware~QARun~QADemo Version 3" Exercise 5A: Bitmap and Text Checks Objective - Perform some high level checks against QADemo - Use the Grid Filter functionality Instructions Step Action 1. Create a new script (using the New Button or File|New) and select Script. 2. Switch Learn ON using {Control L } or select the Record button. 3. Learn the process of starting version 1 of QADemo by selecting the following Start menu option … "Programs~Compuware~QARun~QADemo Version 1" 4. When QADemo appears sign on using the userid DTL and the password PASS. Select a Location. Press OK. Press Cancel on the New dialog which is displayed after logging in to QADemo. 5. Use {Alt {F8}} to insert a check. Create a Bitmap Check against the QADemo Main Window Toolbar. When the Browse Checks window pops up, press New. Screen 6. Select a Bitmap Check and press OK. 7. Give the check a logical Name. 8. Press the Identify button, then place the cross hairs on the bitmap to checked.( QADemo Main Window Toolbar). 9. Click on the Exclude Areas tab to view the captured image. Press OK on the Bitmap Check dialog. NOTE: QARun will return to learn mode. 30 10. Select Menu Option File|Main Options in QADemo. 11. Select Customer Invoice from the list and press OK. 12. Select Print from the Customer Invoice dialog. 13. The Print Preview screen is displayed. 14. Use {Alt {F8}} to insert the following check. Create a Text Check against the Print Preview screen. When the Browse Checks window pops up, press New. 31 15. Select a Text Check and press OK. 16. Give the check a logical Name. 17. Press the Identify button, then place the cross hairs on the Print Preview Title Bar. Click the left mouse button. The Text Captured screen is displayed. The Text Check dialog is present behind the Text Captured dialog. 18. 32 19. Click on the Text Check window and then select the Include Areas tab. 20. Press the New button and capture the date starting with day of the week and ending with year on the Text Captured screen. Select the Date button on the Text Check dialog. Enter Www Mmm DD YY in the Format field. 21. Ensure the Any Valid Date radio button is selected. 22. Select the Include Areas tab of the Text Check dialog. 23. Press the New button and capture the time starting with the hour and ending with minutes on the Text Captured screen. 33 24. Select the Time button on the Text Check dialog. Enter HH:MM in the Format field. Ensure the Any Valid Time radio button is selected. Click the OK button to save the check and return to learn mode. 25. Select the Cancel button on the Print Preview dialog. Select the Close button on the Customer Invoice dialog. 26. Close down QADemo by selecting File|Exit from the menu. 27. Switch learning OFF using {Alt {F10}}. Run the script saving as EX05A. Press OK. Use the existing environment FILTER. Press OK. The Log View is displayed when the script completes execution. 34 28. Press the Select Filter button. Select Passed and Failed Checks from the Select Filter dialog. Press OK. 29. 30. 31. 32. Modify the script so that it executes the second version of QADemo. This is done by changing the 1 to a 2 in the PopupMenuSelect line. Run the modified script and view the log that is generated. Filter out all but passed and failed checks. Use the Filter Manager to create a new filter. Press the Add button on the Filter window to create a new filter. 35 33. Give the new filter a descriptive name. Press the OK button. 34. Click on the Criteria tab to select what will be displayed when this filter is in use. In the Attributes column, select the type of data to be included in the display. In the Filter Criteria column, select the specific values for the type of data. The selections in the field criteria column are the only values to be displayed in the log. Press the OK Button NOTE: The Log will display the filtered data when this script is ran later. 35. Filter Manager can also be used to filter entries containing lots of information, not just log files. Click on File|Browse menu. Select “Object Map”, and press OK 36 36. Use the Filter Manager to create another filter. 37. Press the Add button on the Filter window to create a new Object Map filter. 38. Give the new filter an appropriate name. Press the OK button. 37 39. Click on the Criteria tab to select what will be displayed on this object map currently in use. In the Attributes column, select the type of data to be included in the display. In the Filter Criteria column, select the specific values for the type of data. The selections in the field criteria column are the only values to be displayed in the object map. Press the OK Button 40. The new Object Map displays the filtered data. Points Learned Creating Bitmap and Text checks Creating checks while learning a script Viewing log files and filtering out unwanted commands 38 Exercise 5B: BitMap and Text Checks Objective - Perform some high level checks against Testbed Notes: Under the learn Options - Make sure BitMapSelects are disabled - Create Attached Alias and Enable Attached Mapping are checked - Pause Threshold set to 1 Under Run Environment settings - Replay with pause mode turned on Step 1. Instructions Action Create a new script (using the New Button or File|New) and select Script. 2. Switch Learn ON using {Control L } or select the Record button. 3. Learn the process of starting version 1 of TestBed by selecting Start|Run and typing the full path name for Testbed. Screen (i.e., C:\progra~1\Compuw~1\qarun\demos\ testbed.exe -V1) 4. From the menu, select Session|Connect When Testbed sign on screen appears enter the userid L DTL with the password as PASSDTL. Press Enter 5. Use {Alt {F8}} to insert the following checks. QARun pauses the Learning process to insert a check. 39 6. Create a Bitmap Check against the Testbed main window. When the Browse Checks window pops up, press New. NOTE: This check will be an absolute bitmap check. 7. Select a Bitmap Check and press OK. 8. Give the check a meaningful name. Press the Identify button, then place the cross hairs on the titlebar of the Testbed Main Window. Click on the Type tab. 40 9. Click on the Capture Screen radio button and the Rectangle Pushbutton 10. Draw a box around the toolbar. By selecting the Exclude tab you can verify the results of the capture. 11. Press OK. 41 12. Create a bitmap check on the Testbed Toolbar help Icon. When the Browse Checks window pops up, press New. NOTE: This check will be a window bitmap check. 13. Select a Bitmap Check and press OK. 14. Give the check a meaningful name. Press the Identify button, then place the cross hairs on the titlebar of the Testbed Main Window. Click on the Type tab. 42 15. Click on the Capture Window radio button and the Rectangle Pushbutton 16. Draw a box around the Help Icon. 17. Press OK 18. Create a Text Check that includes only the Testbed Version Number. When the Browse Check Window pops up Press the New button 43 19. Select Text and press the OK button 20. Give the check a meaningful name. Press the Identify button, then place the cross hairs on the titlebar of the Testbed Main Window. Press OK. 21. 44 Select the Include Areas Tab Press the New button Draw a box around the Version Number (3.1) 22. Select the Numeric tab Click on the Equal to radio button. Press OK 23. 24. Close down Testbed by selecting File|Exit from the menu. Switch learning OFF using {Alt {F10}}. 25. Run the script saving as EX05B. Press OK. Use the existing filter FILTER, with logging set ON. Press OK. 26. View the log that is generated. Filter out all but passed and failed checks. Points Learned Creating Bitmap and Text checks Creating checks while learning a script Viewing log files and filtering out unwanted commands 45 Exercise 6A: Timing Checks Objective - To find out how long it takes to load QADemo and attach to it - Use the command Wizard - Clock check involves… reset, start, stop, compare Notes: - Logging should be turned off while the time is being measured Instructions Step Action 1. Create a new script (using the New Button or File|New) and select Script. 2. Switch Learn ON using {Control L } or select the Record button. 3. Learn the process of starting version 1 of QADemo by selecting the following Start menu option … "Programs~Compuware~QARun~QADemo Version 1" 4. When QADemo appears sign on using the userid DTL and the password as PASS. Press OK. Press Cancel on the New dialog which is displayed after logging in to QADemo Screen 5. Close down QADemo by selecting File|Exit from the menu. 6. Switch learning OFF using {Alt {F10}}. 7. Modify the learned script by adding the following commands using Command Wizard: At the top of the script, after Function Main insert the two commands: • ClockReset • ClockStart After the Attach “New PopupWindow” insert the following command: • ClockStop 8. Be sure the Clock names are the same for all three commands. Place the cursor in the script after the ClockStop command. Insert a clock check by selecting the Menu Option Insert|Check|Clock.... 9. 48 When the Browse Clock Checks dialog appears, press the New Button. 10. When the Clock Check dialog pops up, use the same name used in the clock commands in step 7. Select the Timings Tab. Select the Between Radio button. Enter 0.1 and 2 seconds as the range. Press OK on the Clock Check dialog. The Clock Check will be pasted in the script. 11. Run the script saving as EX06A. Press OK. Use the existing environment FILTER. Press OK. The Log View is displayed when execution is complete. 12. To see the recorded time of the clock, press the Grid Column Layout button. 13. Press the ADD Button the create a new Column Layout. 14. Enter a name for the new column layout. Press the OK button. 49 15. Select Notes from the Column Not Shown section. Press the Show button. Select Notes from the Columns Shown. Press the Up button repeatedly, until Notes is third from the bottom. Press OK. 16. The recorded time is displayed in the Notes column of the Log View. If the Clock Check fails as indicated in Red because it is outside the range, edit the check by double clicking on the check name in the log view and change the range of the timing. Note: The check can also fail if the clock check was not set up correctly. 17. If Time Permits... Build a Repeat...Until loop to execute 5 times. Start the loop before pressing the Start button and end it after exiting the application. Points Learned Creating a Clock check Automation techniques 50 Exercise 6B: Timing Checks Objective - To find out how long it takes to load Testbed and sign on to it Notes: - Pause mode must be turned on - Pause threshold set to 1 Instructions Step Action 1. Create a new script (using the New Button or File|New) and select Script. 2. Switch Learn ON using {Control L } or select the Record button. 3. Learn the process of starting version 1 of TestBed by selecting Start|Run and typing the full path name for Testbed. (i.e., C:\progra~1\Compuw~1\qarun\demos\ testbed.exe -V1) 4. From the menu, select Session|Connect When Testbed sign on screen appears sign on using the userid L DTL and the password as PASSDTL. Press Return 5. 6. 7. Disconnect by selecting “Session|disconnect from the Testbed menu . Close down Testbed by selecting File|Exit from the menu. Switch learning OFF using {Alt {F10}}. Screen 8. Save as EX06B and run it making sure it works. 9 Modify the learned script by adding the following commands at the beginning of the script: ClockReset(Clock Name) ClockStart (Clock Name) Insert the ClockStop(Clock Name) after the Type “Return” statement for the Testbed log in window. Use Log.Enable = 0 to turn logging off so the overhead associated with logging is not included in the time between the ClockStart and ClockStop command. 10. Create a clock check by selecting the menu option Insert|Check|Clock. Insert the check at the end of the script. Use Log.Enable = 1 to turn logging on before performing the Clock Check. 52 clockstart("clock1") ; Type "l dtl{Tab}passdtl" Pause 1, 'Seconds' Type "{Return}" clockstop("clock1") Pause 2, 'Seconds'; 11. When the Browse Clock Checks dialog appears, press the New Button. 12. When the Clock Check dialog pops up, give the check the same name as used in the clock functions in step 9. Select the Timing Tab. Select Between. Enter 0.1 and 2 seconds as the range. Press OK. The Clock Check will be pasted in the script. 13. Run the script EX06B. 14. To see the recorded time of the clock, press the Log View Column Layout button to modify the Layout and add Notes to the columns shown. 15. Select Notes from the Column Not Shown section. Press Show. Move Notes up before Check Generation. Press OK. 16. If the Clock Check fails because it is outside the range, edit the check by double clicking on the check name in the log view and change the range of the timing. 17. If Time Permits ... 53 Build a Repeat...Until loop around the script to execute 5 times. Produce a Statistical Report from the generated log by selecting View|statistics from the QARun menu. Points Learned Creating clock checks Obtaining Statistical Reports 54 Exercise 7A: Automating a Host Objective - To automate the process of starting and unloading QADemo using screen and window events Notes: In Options|Configure/Editor, ensure the Use Wait Timeout option is checked and Wait Event Timeout is 10. Instructions Step Action 1. Create a new script (using the New Button or File|New) and select Script. 2. Switch Learn ON using {Control L } or select the Record button. 3. Learn the process of starting version 1 of QADemo by selecting the following Start menu option … "Programs~Compuware~QARun~QADemo Version 1" 4. Using the event hotkey {Alt{F7}} , create a screen event to wait for the “Enter Sign on Details” screen. 5. Select the New button from the Browse Events dialog. Screen 6. Select the Screen radio button and press the Event OK button. 7. Enter a meaningful Event Name and Comment. Press the Next button. 8. Press the Identify button. 9. Position the cursor over the title bar of the Enter Sign on Details screen and click the left mouse button. The object name should appear in the Attach field. Press the Next button. 56 10. Check the Use Rectangle option and press the Capture button. 11. Draw a box around the text “User ID:” on the window. Click the Left Mouse button. When the window text appears, press the Finish button. 12. 13. Insert the event into the script as a Wait event by pressing the Wait button. The event is also added to the event map where it is available for use by other scripts. 14. When QADemo appears sign on using the userid DTL and the password as PASS. Select a Location. Press OK. 57 15. Using the event hotkey {Alt{F7}}. Create a screen event to wait for the New window. 16. Select the New button from the Browse Events dialog. 17. Select the Screen radio button and press the Event OK button. 18. Enter a meaningful Event Name and Comment. Press the Next button. 58 19. Press the Identify button. 20. Position the cursor over the title bar of the New window and click the left mouse button. The object name should appear in the Attach field.. Press the Next button. 21. Check the Use Rectangle option and press the Capture button. 22. Draw a box around the “New” text on the window. Click the Left Mouse button. 59 23. When the window text appears, press the Finish button. 24. Insert the event into the script as a wait event by pressing the Wait button. The event is also added to the event map where it is available for use by other scripts. 25. At this point you should be back in Learn mode. Learn the keystrokes to cancel the “New” dialog box and Maximize QADemo. 26. 27. Stop Learning {Alt {F10}} Select the menu option Insert|Event|Window Create a window event that waits for the QADemo main window not to exist. Press the New button. 60 28. Give the event a meaningful Event Name and Comment. Press the Next button 29. 30. Press the Identify button and position the cursor over the title bar of the QADemo window and click the left mouse button. The object name should appear in the Attach field. Press “Next” button 31. Select the NotExists option and press the Finish button 32. Press the Wait button to insert the event in the script and to enter into the event map for use in other scripts. 33. Return to Learn mode using {Control L} 61 34. Close down QADemo by selecting File|Exit from the menu. Stop learning using {Alt {F10}} 35. 36. Modify the script by moving the Wait statement and the If .. Else .. Endif statements inserted in Step 32 to the end of the script, just before the End Function command for the Main function. Review the Script, save it as EX07A, and run it to make sure it works properly. Points Learned Synchronizing QARun script execution with an application using screen and window events 62 Exercise 7B: Automating a Host Objective - Using screen events to automate the process of starting and unloading TestBed Notes: - Replay with pause mode turned off - HotKey for inserting events - Alt-F7 Instructions Step Action 1. Create a new script (using the New Button or File|New) and select Script. 2. Switch Learn ON using {Control L } or select the Record button. 3. Learn the process of starting version 1 of TestBed by selecting Start|Run and typing the full path name for Testbed. (i.e., C:\progra~1\Compuw~1\qarun\demos\ testbed.exe -V1) 4. From the menu, select Session|Connect Define a screen event to look for “USERID” on the Testbed logon screen. Name this event “UseridTestbed” Use hotkey Alt-F7 to exit learn mode and bring up the Browse Events window Press the New button 5. Select Screen Event and press the OK button Screen 6. Enter the name “UseridTestbed” and press the Next button. 7. Press the identify button, position the crosshairs over the title of the window and left-click the mouse. When the attach name appears, press the Next button. 8. Click the Use Rectangle checkbox and press the Capture button 64 9. Draw a box around the “Userid” text and press Finish 10. Insert the event as a Wait Event 11. When Testbed sign on screen appears sign on using the userid L DTL and the password as PASSDTL. Press Return 12. 13. 14. When the Testbed main menu appears, repeat steps 4-10 defining a screen event that looks for the text “[F1]Maintenance”. Name this event “MainmenuTestbed” Learn the key sequence to navigate to the Customer Master Maintenance Menu, Function key F1. When the Customer Master Maintenance Menu appears, repeat steps 4-10 defining a screen event that looks for the text “[F1] - Customer Credit Det.” Name this event “MasterMaintTestbed”. 65 15. Press Escape to return to the Main Menu and insert the event “MainMenuTestbed” using the hotkey combination Alt-F7. When the Browse Event pop-up window appears, select the appropriate event and press the insert button. 16. 17. 18. 19. 20. Let the wizard lead you through the process of inserting the correct event. You should press the Next key twice and then Finish selecting the Wait Event Press Escape to return to the Logon screen and insert the event “UseridTestbed” following the same procedure as indicated in the previous step. Disconnect from Testbed by selecting “Session|Disconnect from the Testbed menu. Close Testbed using File|Exit Run the script saving as EX07B. Points Learned Synchronising using screen events 66 Exercise 8: Creating Image Map Entries Objective - Use the image map to interact with an application which uses a bitmap as its primary user interface - View the image maps in the Image Map window - A first look at using QARun’s functionality to understand different ways to learn a script Notes: - Take care to position the mouse pointer directly over the calculator numbers and characters - A script must be open to access the “learn” options - Options are listed in alphabetical order Instructions Step Action 1. In Options|Learn Settings|General Tab deselect the TextSelects and BitmapSelects options. 2. Start the calculator program. Start learning a new script using the mouse to calculate the multiplication of these two numbers: 7*9= When the result is presented, press the C key to clear the display. Stop learning and view the script. Screen 3. 4. 5. The Calculator application was not programmed to use regular buttons for the number keys. Since no individual buttons exist, the script records where the mouse was clicked on the main window. To make the script more readable, create new image maps for the “7” key and the “*” key. Press the Image Map toolbar button. Select File/New from the menu to create a new image map. Use the name below as the image name for the calculator key “7”. Calc 7 Enter a description of the image. This description can be read from the Image Map Window 6. Select the Capture button and draw a box around the “7” key in the calculator application. Press the Preview Image key to review the captured Image. Press the “OK” button. 68 Attach "Calculator MainWindow" MouseClick 82, 97, 'Left SingleClick' MouseClick 200, 203, 'Left SingleClick' MouseClick 161, 100, 'Left SingleClick' MouseClick 239, 199, 'Left SingleClick' MouseClick 234, 62, 'Left SingleClick' 7. Create an image map for the “*” key. Notice the image map can not contain special characters. In this case, use the character “X” to indicate the “times” key. Press the “OK“ button. 8. The two new image maps will be displayed in the Image Map window. Close the Image Map window. 9. In Options|Learn Settings|General Tab turn on the BitmapSelects option. 10. Start learning in the same script by using the mouse to calculate the multiplication of two numbers: 7*9= When the result is presented, press the C key to clear the display. Stop learning and view the script. 69 11. 12. 13. Since the images of the “7” and “*” keys were predefined, The BitmapSelect command used it in the script. New image maps were created for the rest of the keys used. In the BitmapSelect "Calculator" command double click on the word “Calculator” to view the automatically capture image or review the new entry in the Image Map. In Options|Learn Settings|General Tab deselect the BitmapSelects option and select the TextSelects option. Attach "Calculator MainWindow" BitmapSelect "Calc 7", 'Left SingleClick' BitmapSelect "Calc X", 'Left SingleClick' BitmapSelect "Calculator", 'Left SingleClick' BitmapSelect "Calculator_0000", 'Left SingleClick' BitmapSelect "Calculator_0001", 'Left SingleClick' Start learning in the same script by using the mouse to calculate the multiplication of same two numbers. 7*9= Be sure to click the mouse on the character or number, not just within the button. When the result is presented, press the “C” key to clear the display. Stop learning and view the script. 14. This script is easier to read. 15. In Options|Learn Settings|General, deselect TextSelects. 70 Attach "Calculator MainWindow" TextSelect "7", 'Left SingleClick' TextSelect "*", 'Left SingleClick' TextSelect "9", 'Left SingleClick' TextSelect "=", 'Left SingleClick' TextSelect "C", 'Left SingleClick' 16. Start learning in the same script by using the keys at the top of the keyboard to calculate the multiplication of two numbers. Attach "Calculator MainWindow" Type "7*9={Escape}" 7*9= Be sure to use the keys at the top of the keyboard, not the keys to the side of the keyboard. The ESC key can be used to clear the display area. When the result is presented, press the “C” key to clear the display. 17. Stop learning and view the script. Save script as EX08. Which of the previous methods of capturing this script is the easiest to maintain if several sets of numbers were to be calculated? Of the scripts that used the mouse, to test mouse click interaction with the application, which will be the easiest to maintain? Points Learned TextSelects and BitmapSelects 71 Exercise 9A: Setting the Editor Environment Objective - Tailoring the QARun editor environment - Observing how changing the QARun Learn options affects the way learns an application. - Script can be learned several ways Notes: - You may wish to alter the color configuration in the script editor - Set up your Default Script layout - Script must be open to access the “learn” option Instructions Step Action 1. Select Options|Configure to change any of the QARun settings related to Colors, Editor, Hotkeys, Replay and Default script. 2. Select Options|Change Fonts to change the font of the text displayed within the editor. Set the fonts as desired and press OK. Screen Qarun 3. From the Menu, Options|Learn Settings verify that the Tab Key, TypeToControl and Edit options are not checked. The Tab and TypeToControl options are found under the General property sheet and the Edit options are found under the Mouse/Keys property sheet. Press OK 4. Select Start/Programs/Compuware/QARun/QADem o Version 2 from the Start Button Menu. 5. Log into QADemo using the following information: • User ID: dtl • Password: pass Select a Location radio button. Press the OK Button. 6. Click on the Add Car option in the New listbox. Then press the OK Button. 74 7. Return to QARun and start learning. Enter the displayed information into the Add Car fields. Use the tab key to navigate from field to field. Stop learning the script by using the {Alt{F10}} keys. 8. Review the script. Notice the script did not learn the use of the TAB key. The TAB key is not needed when the EditText command is used. 9. EditText is the default command used to interact with edit field objects. NOTE: At times, the TAB key should be captured. In Options|Learn Settings|General property sheet select the Tab Key option. This allows the capture of the TAB keys. Attach "Add Car ChildWindow" EditText "&Ref :", "car1" EditText "&Make :", "make of car" EditText "&Engine size :", "V8" EditText "&Year :", "1998" EditText "&Doors :", "4" EditText "&Color :", "Red" 75 10. Press the Close button and reopen the Add car window. Start learning. Enter the displayed information into the Add Car fields again tabbing from field to field. 11. Stop learning the script and review the script. Notice how much more cluttered the script appears. The command to type the TAB key is now included between the EditText commands. This may be harder to maintain than the prior script. *** Only part of the script.***** Attach "Add Car ChildWindow" EditText "&Ref :", "car1" Attach "~N~QADEMO.EXE~Edit~&Ref :" Type "{Tab}" Attach "Add Car ChildWindow" EditText "&Make :", "make of car" A different set of learn options can be used to Attach "~N~QADEMO.EXE~Edit~&Make :" Type "{Tab}" learn the script so the script will include the TAB keys and will be easier to maintain. Attach "Add Car ChildWindow" EditText "&Engine size :", "v8" Attach "~N~QADEMO.EXE~Edit~&Engine size :" Type "{Tab}" 12. For the QADemo application the best the QARun Learn options are: Tab Key = checked TypeTo Control = checked Edit = checked Make sure those selections are set. Selecting the Edit Mouse/Keys option will cause QARun to NOT use the EditText command when learning. Selecting the TypeToControl will cause QARun to replace the EditText command with the TypeToControl command. Press the OK Button 76 13. In QADemo, Press the Close button on the Add Car window. Select File|Main Options and select the Add Car option to reopen the Add Car window. Re-Learn the same application interaction. Stop learning the script and review the script. 14. Notice the script is much easier to read and maintain while it still learns the TAB keys. 15. Reset the Learn options to: Tab Key = not checked TypeTo Control = not checked Edit = not checked 16. Save the Script as EX09A. Attach "Add Car ChildWindow" TypeToControl "Edit", "&Ref :", "car1{Tab}" TypeToControl "Edit", "&Make :", "make of car{Tab}" TypeToControl "Edit", "&Engine size :", "v8{Tab}" TypeToControl "Edit", "&Year :", "1998{Tab}" TypeToControl "Edit", "&Doors :", "4{Tab}" TypeToControl "Edit", "&Color :", "red" 77 Points Learned Configuring the QARun editor environment 78 Exercise 9B: Setting the Editor Environment Objective - Tailoring the QARun editor environment Notes: - You may wish to alter the color configuration in the script editor - Set up your Default Script layout - Script must be open to access “learn” options. Instructions Step Action 1. Use Options|Configure|Colors to change the color coding schemes in the QARun editor settings. Set color as desired. 2. Use Options|Configure|Editor to change the way the QARun editor settings. Highlight each options to observe what the option controls. 3. Use Options|Configure|HotKeys to change any of the QARun HotKeys. Screen 4. Select Options|Configure|Replay, Highlight each of the Replay options to observe their meaning. Note: Suggested defaults are shown at the right. 5. Select the Options|Configure |Default Script tab to view the current default script. Press the “OK” button. 6. Use Options|Change Fonts to change the font of the text displayed within the editor. Set fonts as desired and press the “OK” button. Points Learned Configuring the editor environment 80 Exercise 10A: Creating Object Map Entries Objective - Comparison between Attach names… Static and Object Maps - How to automatically generate Object Map entries - How to define which objects will receive Object Maps - How to deal with changes to the Object Maps - Comparing Object Maps Notes: - A script must be open in order to access configuration options Instructions Step Action 1. Ensure that Create Attach Aliases and Enable Attach Mapping configurations are not selected (no check mark). These settings are found under the QARun menu, Options|Learn Settings| Attach Logic property sheet. 2. Screen Select Start/Programs/Compuware/QARun/QADemo Version 1 and log in with: User ID: dtl Password: pass Press the OK Button. 3. Press Cancel in the New dialog box. 81 4. Learn the following sequence in QADemo: Select File|Main Options. Note: Initiate “Learn” mode by clicking on the red “learn” icon 5. Select Inquire and click OK. 6. Select Close to exit the dialog. 7. Stop learning and view the script. Look at the static Attach names that were captured. Attach "~U~EXPLORER.EXE~Shell_TrayWnd~" Attach "~N~QADEMO.EXE~#32770~New" Attach "~N~QADEMO.EXE~Afx~QADemo" 8. Enable object mapping by checking Create Attach Aliases and Enable Attach Mapping. These settings are found under the QARun menu, Options|Learn Settings| Attach Logic property sheet. Initiate learn and Repeat Steps 4-6. 9. 82 Stop learning and view the script. Are the Attach "PopupWindow~1" Attach names more descriptive? Attach "Inquire ChildWindow" Attach "QADemo MainWindow" 10. 11. Close QADemo using the File|Exit menu option. Save the script as EX10A. Press OK. Points Learned Differences between no Object Mapping ( Static names ) and Automatic Object Mapping 83 Exercise 12A: Creating Driver Scripts Objective - To build a driver script which executes a number of test scripts. - How scripts called by a driver script can receive variables from the Driver script. Notes: None Instructions Step Action 1. Create a new script (using the New Script Toolbar Button). Screen 2. Using the Command Wizard, insert a Run command into the script that will run EX04A. Run (“EX04A”) 3. Insert another command that will run script Ex05A. Run ("EX05A") 4. Add a local variable which will be passed to a script from within the driver. (Var Passed_Value) Insert a command that will run a new script that uses a passed variable. See example 5. Create a new script with the following command… Save script as PassParameter. 6. Execute the script and review the log file. Points Learned Running scripts from a driver script 85 Running scripts from a driver script and analyzing the return code Declaring a public variable and passing it to a child script 86 Exercise 12B: Creating Driver Scripts Objective - To create a driver script which executes a number of test scripts Notes: Step 1. 2. Instructions Action Start a new script in the editor Within the function main add the command to run a script that executes successfully. Screen Run (“EX05”) Use the command wizard to make sure of the syntax 3. 4. 5. In EX12B declare a variable to be public. Notice the declaration resides outside of the function “main” public a Add a command to run another script. Call this new script “child”. Run ("Child") Within the child script, declare the variable identified in step 4 to also be public. Using the “textpanel” command display the value of the public variable. Textpanel(1, "the value of a= " +a) Sleep 3 Function Main The sleep command is necessary so the textpanel can be viewed. Run EX12B and watch to make sure the public variable is displayed. Points Learned Writing driver scripts Understanding the relation ship between driver scripts and test scripts Use of public variables 87 Exercise 13A: Modularizing Scripts Using Functions Objective - Structuring scripts through the use of functions Notes: A script can contain only one function main Functions begin the name of the function and end with the statement “End Function” Instructions Step Action 1. Create a new script (using the New Button or File|New) and select Script. 2. Switch Learn ON using {Control L } or select the Record button. 3. Learn the process of starting version 2 of QADemo by selecting the following Start menu option … Screen "Programs~Compuware~QARun~QADemo Version 2" 4. When QADemo appears sign on using the userid DTL and the password as PASS. Select a Location. Press OK. 5. Press Cancel on the New dialog which is displayed after logging in to QADemo. Navigate the application to the New window and back to the main window. Close QADemo (File|Exit) 6. Stop learning Run the script saving it as EX13A. Be sure the script executes correctly. 89 7. Create the function Startup. This function will start QAdemo. Create another function Shutdown. This function will exit QAdemo. These functions must be placed outside the Function Main. Generally, new functions are placed at the end of the script. Using the editor, highlight the commands that startup QAdemo, cut them from the Function Main and paste them into the newly created function Startup. Function Main End Function ; Main Function StartUp() ; Commands to start QADemo and navigate to the main window. End Function Function ShutDown() ; Commands to exit QADemo End Function Using the editor, highlight the commands that exit QAdemo, cut them from the Function Main and paste them into the newly created function Shutdown. 8. Modify the script by inserting calls to these functions at the correct places within the Main Function. Proper syntax to call a function is shown on the right. Function Main StartUp() ShutDown() End Function ; Main 9. 10. 11. 90 Run the script to make sure it executes correctly. If time permits, move the two functions just created into another script and name this script EX13C. Use the “Include” statement to pull script EX13C into EX13A. Also if time permits, create a script that calls a function that will add two numbers passed to it and return the result. Display the result using a “textpanel” statement, use the command wizard for proper syntax. Points Learned How to create functions How to call functions Where to place functions within a script 91 Exercise 13B: Modularising Scripts Using Functions Objective - To structure scripts with the use of functions Notes: Step 1. 2. Instructions Action Load Ex07B and save it as Ex13B. Create the function Login. This function will start and log into Testbed. Create another function Logout. This function will exit Testbed. These functions must be placed outside the Function Main. Generally, new functions are placed at the end of the script. 3. Using the editor, highlight the commands that startup Testbed, cut them from the Function Main and paste them into the newly created function Login. Screen Function Main End Function ; Main Function Login() ; Commands to start Testbed and enter the userid and password. End Function Function Logout() ; Commands to exit Testbed End Function Function login() Attach "PopupWindow~1" Button "Start", 'Left SingleClick' PopupMenuSelect "Run..." Attach "Run PopupWindow" ComboText "&Open:", "c:\testbed\testbed.exe -v1" Button "OK", 'Left SingleClick' Attach "Testbed for Windows V1.00 MainWindow" Size 600, 411 Move 132, 132 MenuSelect "Session~Connect..." If Wait(30, "", "userid") = 1 ; Event Passed Else ; Timeout of 30 seconds has been exceeded EndIf Attach "Testbed for Windows V1.00 Connected MainWindow" Type "l dtl{Tab}passdtl{Return}" If Wait(30, "", "mainmenu") = 1 ; Event Passed Else ; Timeout of 30 seconds has been exceeded EndIf End Function ; login 93 4. Using the editor, highlight the commands that exit Testbed, cut them from the Function Main and paste them into the newly created function Logout. Function logout() Attach "Testbed for Windows V1.00 MainWindow" MenuSelect "File~Exit" End Function ; logout 5. In the Function Main, insert a command to call the function Login(). This call replaces the commands cut from the Function Main. Login() 6. In the Function Main, insert a command to call the function Logout(). This call replaces the commands cut from the Function Main. Run the script. It should function exactly as it did in exercise EX07B. Logout() 7. 8. If time permits move the Login() and Logout() functions into a new script called EX13D. Use the command wizard get the correct syntax for including EX13D in EX13B. Points Learned Program structure Functions 94 Exercise 14A: Adding cars to the QADemo database. Objective - Create a script that will add a car to the QADemo database. This script will be the starting point for the next exercise. Notes: In the Options|Learn Settings|General property sheet, select TypeToControl and Tab Key. In the Options|Learn Settings|Mouse/Keys property sheet, select Edit. Set Pause Threshold = 1000 Instructions Step Action 1. Create a new script. Screen Make sure the settings in the Notes above have been set. Start learning 2. Start version 2 of QADemo by selecting the following Start menu option … "Programs~Compuware~QARun~QADemo Version 2" 3. When QADemo appears sign on using the userid DTL and the password as PASS. Select a Location. Press OK. 95 4. Press Cancel on the New dialog which is displayed after logging in to QADemo. 5. Maximize the QADemo main window, and select File/Main Options. Navigate the application to the Add Car screen by clicking on the Add Car list entry and pressing the OK button. 6. 96 Fill in the data on this screen as follows: Field Data Ref ---------------------Car1{Tab} Make-------------------Car Make{Tab} Engine size-----------Engine{Tab} Year--------------------98{Tab} Doors-------------------4{Tab} Color--------------------Blue {Tab} Sale Price-------------1000{Tab} Deal Discount--------5{Tab} Quantity----------------1{Tab} Dealer Price----------{Tab} Radio-------------------MouseClick 4WD--------------------MouseClick Sun Roof--------------MouseClick Leather----------------MouseClick Air Cond---------------MouseClick Metallic----------------MouseClick 7. Click on the Add and then the Close button. 8. Close down QADemo by selecting File|Exit from the menu. 9. 10. Exit Learn mode using the hotkey {Alt-F10} Change the Ref value recorded in the script from car1 to car2. TypeToControl "Edit", "&Ref :", "car2{Tab}" Run the script saving it as EX14A. Ensure the script runs completely. Points Learned Automating the entry of data into an application 97 Exercise 14B: Creating an Account on the Host Objective - To create an account on the host system Notes: - It will be necessary to restore the Testbed database each time this script is run. This can be accomplished by copying the file Testbed.sav to Testbed.dat. Use the command wizard to construct this command. Instructions Step Action 1. Create a new script (using the New Button or File|New) and select Script. 2. Switch Learn ON using {Control L } or select the Record button. 3. Select Start/Programs/Compuware/QARun/TestBed Version 1 from the Start Button Menu. Screen From the menu, select Session|Connect 4. 5. Insert the screen event that waits for the logon screen to appear. Event name =UseridTestbed When Testbed sign on screen appears sign on using the userid L DTL and the password as PASSDTL. Press Return 99 6. Insert the screen event that waits for the main menu to appear. Event name = MainmenuTestbed 7. Press the function key “F1” and insert the screen event that waits for the “Customer Master Maintenance Menu”. Event name = MasterMaintTestbed 8. Press the following keystrokes: “A” to select the add function. “Tab” to the “customer” field. Enter “999” for customer number. 9. Press “F2” to advance to the Customer Master Basic Data screen. Create a screen event to wait for this screen. Name this event CustomerMasterDataTestbed. 10. 100 Enter the following information: Cust Name = Jones Address 1 = 5 High St. Address 2 = New Town Address 3 = Surrey Address 4 = Uk Abbrev 1 = SY Cash Code = 10 Contact = Sarah Supp A/C = 91827364 Yr Bus ST = 1002 Console IND = 10 Postcode = KT19 8zx Phone = 0123 456 789 11. Press the “F1” key to save the information in the database 12. Create a screen event that waits for the following message to appear: “Customer Record Updated” Name this event CustomerUpdatedTestbed. 13. Press “Escape” to return to the Customer Master Maintenance Menu Insert the screen event created previously to wait for this screen. Event name = MasterMaintTestbed 14. Press “Escape” to return to the Main Menu. Insert the screen event to wait for this screen. Event name = MainMenuTestbed 15. Press “Escape” to return to the logon Screen. Insert the screen event to wait for this screen. Event name = UseridTestbed 101 16. From the menu select Session|Dis-Connect Press the pushbutton “Yes” 17. Select File|Exit to exit the application 18. Save the script as EX14B and run. Points Learned Automating the entry of data into an application 102 Exercise 15A: Data Input using a Test Data File Objective - Understand how to modify a script to read from a data file Modify the commands to read from the data file Identify the name of the data file Insert the top and bottom of the loop to read the file Build the data file - Some commands know how to “read” from a data file, other commands need to use the TestDataTransform command to transform the data file information into something the command can use Notes: Review the data file addcars.csv that the instructor has provided Instructor will supply the test data file or else you can build it with the information that follows the Instructions The QADemo database cannot contain duplicate reference numbers. If the script is run multiple times, it will be necessary to delete the cars The TestDataCurRecord and TestDataRecordCount functions can be used to determine if the data file was completely processed Instructions Step Action 1. Load the script EX14A and save as EX15A. 2. Review the script. Screen Notice some of the commands are used to navigate to the window in which the data will be entered. Other commands interact with the objects, e.g. enter text to edit fields or click on check boxes. Other commands are used to navigate off the window. The first step in modifying the script is to change the commands using data. The changes will give the commands the ability to read from the datafile. 103 3. First, modify the TypeToControl commands. TypeToControl "Edit", "&Ref :", "Car1{Tab}" TypeToControl "Edit", "&Make :", "Car Make{Tab}" The cell to the right illustrates how the edit field was captured by QARun. The TypeToControl command can interact with the data file directly. To modify the command, replace the original data with the data file reference ( e.g. {+.1} ) . 4. 5. 6. 104 Notice the &Ref field is the first field used from the data file. Every time this command for the &Ref field is used, it should read the first field of the next record in the file. For this reason, the data file reference should be {+.1} and should be the only hard coded reference to a field or record. TypeToControl "Edit", "&Ref :", "{+.1}{Tab}" TypeToControl "Edit", "&Make :", "{=.+}{Tab}" Every other object in the script will be using a field located on the same record. Also, the data for each object in the script is located next to the data for the last object. So all the rest of the commands in the script will be using the {=.+} data file reference. Delete the "Dealer Price" line in the script because it is a calculated field. TypeToControl "Edit", "Dealer Price :", "{Tab}" When a check box is clicked, it will toggle the value currently represented. Therefore to positively indicate the value of a checkbox, the data file must contain either “ON” or “OFF”. 7. Review the Checkbox command in the help text. Select the menu option Help/Language Help and enter Checkbox in the Index. Press the Display button. 8. 9. 10. Notice the help text indicates the CheckBox command has two of many options which will be useful, on and off. So, the words on and off can be used in the data file to specifically select or deselect the checkbox. Another issue with the checkbox command is that it can not read from the data file. The TestDataTransform function must be used to translate the data file information into something the checkbox command can use. Syntax ret = CheckBox( "ControlId", "Options", x, y ) … "Options" The options are as follows: … "on" Select the check box. "off" Deselect the check box. … Checkbox "Rad&io", TestDataTransform("{=.+}") The example in the cell to the right shows how the Checkbox command can be modified to read data in from the data file. Continue to modify the rest of the checkbox commands. Be careful not to modify the button commands which follow the checkbox commands. 105 11. 12. 13. 14. Since the script is now modified to read from a data file, It would be a good time to define which data file will be used for this script. Use the example, in the cell to the right, to modify the script so it references the test data file named “c:\testdata\addcars.csv” before the attach name for the window. Testdata (“c:\testdata\addcars.csv”) Note: the actual location of the file will vary. It depends on where you place it. Loading the script with the TestData command has completed the process of modifying the script to read from a data file. But, we wish to use the data file to load several records into the application. This means a loop must be used in this script to load more than one record. Since at least one record will be used, the Repeat…Until loop will be used. Repeat … Until TestDataRecordCount = TestDataCurRecord Notice the top of the loop, where the repeat command is needed, is just before the Attach name for the input window. The last command to be executed before the next record can be loaded is the Button Add command. So, the end of the loop, the Until command, is placed after the Button Add command. 15. 106 When the bottom of the loop is added, the Button Close command was separated from its attach name. It is good programming practice to copy the attach command from higher in the script and paste it before any displaced commands. Button "Close", 'Left SingleClick' 16. Copy the attach command and place it just before the Button Close command. NOTE: Steps 17-21 are an example of how to document the layout of the testdata file. 17. 18. Create a string containing the object names in the order the fields appear in the script. To be helpful, the string should be located below the TestData command. This string can be used to build the test data file. This will be helpful in the future if any question arises concerning the way the data file was built. 19. Copy this string of object names and paste it into the notepad application. 20. Save the file as a .CSV file with the name and path used in the script. //ref,make,engine size,year,doors,color,price, discount,quantity,radio,4wd,Sun Roof,Leather,Air, Metalic 107 21. This file can be used to build the external data file. A spread sheet program is recommended in building and maintaining an external data file. Open this file from within the spreadsheet program. Add data and save the file as a .CSV file. 22. 108 Otherwise, load the data from within the Notepad.exe file. Run the script to verify it works correctly. This is a sample of the data needed in the data file. Field 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Name Ref Make Engine size Year Doors Color Sale Price Dealer Discount Quantity Radio 4WD Sunroof Leather Air Cond Metallic Example Car10 Ford 1600 1996 4 Red 12500 10 1 on or off on or off on or off on or off on or off on or off Points Learned Automating the entry of data into an application 109 Exercise 15B: Data Input using a Test Data File Objective - To drive an input screen by reading data from a test data file - Introduce the following new commands: - TestData() - TestDataRecordCount() - TestDataCurRecord() Notes: - Instructor will supply the test data file named person1.csv - Modify the editor so it does not generate an IF….Else structure when events are inserted before beginning this exercise. Instructions Step Action 1. Load the script from exercise EX14B and save as EX15B. 2. Modify the script so it references the test data file named “c:\testdata\person1.csv”. Insert this statement as the first statement in the Function Main. Screen Testdata (“c:\testdata\person1.csv”) 3. Locate the commands in the script where data is being entered. Replace the hardcoded data in the script with the correct File Operator Commands. There should be a similar command for each field to be entered. The “tabs” are necessary to navigate from field to field. Type "{Tab}{Tab}{=.+}" ;customer name 4. Build a Repeat…..Until loop around the Customer Master Maintenance Menu screen and the Customer Master Basic Data screen. Repeat Type "a{Tab}" Type "{+.1}" Type "{F2}" If Wait(30, "", "customermasterdata") = 1 : Note: Commands to read the data file and enter the data go here : Until TestDataCurRecord = TestDataRecordCount 5. Run the script to verify it works correctly. 111 Exercise 16A: Testing for Valid and Invalid Data Input Objective -Introduce user-defined logging - To build scripts which will cater to more than one situation - Force an application to generate messages Notes: - Review data file “errorcar.csv”. Note reference nos - Instructor will supply data file. Instructions Step 1. Action Open the exercise EX15A and save it as EX16A. Screen In the Options|Configure|Editor deselect the Use Wait Timeout option. 2. Position the cursor to the line after the Button Add statement. 113 3. Manually navigate the application to this screen and create a Screen Event to look for the new car record to be added correctly. Begin by adding a valid record into QADemo. 4. Press the Add button to save the record. Note the Ref field is cleared or set to null when the record is saved correctly. NOTE: Null field = blank field 5. From the QARun menu, click on Insert|Event|Screen to create an event to look for NULL in the reference field. Name this event "Car Saved". 6. Click on the Identify button and place the cursor in the Ref Number edit field. QARun will use the name of the field as the Attach name. Do not type this information. Use QARun to Identify the object. 114 7. Create the event to look for no text being present in the edit field. 8. Since the event used to signal the addition of the new record was created, the error message event can now be built. Start by adding a record with the same Ref value as an existing record. 9. The following message is displayed. Note the sentence fragment that states… “duplicate value in index” 10. Create a new Screen Event to look for this text in the popup window. Name this event "Duplicate Screen". 11. Identify the popup window as the attach window. 115 12. Use the Rectangle functionality to capture the text "duplicate values in the index". 13. Once the text is captured, uncheck the “Use Rectangle” checkbox. Now if minor changes are made to the message, QARun will still be able to locate this phrase. 14. Note the two wait commands added to the script. 15. Modify the two commands into one “wait” command as shown. Be sure to use the “any” parameter. 116 16. Build the "if" statements as shown to respond to the events by adding the "UserCheck" and "LogComment" statements. These can be typed or use the Command Wizard. If the "QADemo PopupWindow" is not available, force it to be available and record clicking on the "Ok" Button. Also record the keystrokes to delete the data from the reference field. The script should be similar to the one shown on the right. Wait(30, "Any", "Car Saved" , "Duplicate Screen") If event ("Car Saved") UserCheck( "Adding Cars" , 1 , "Car added successfully" ) Endif If event ("Duplicate Screen") UserCheck( "Adding Cars" , 0, "Car not added") LogComment( "The Reference Number " + TestDataTransform( "{=.1}" ) +" was not entered") Attach "QADemo PopupWindow" Button "OK", 'Left SingleClick' Attach "Add Car ChildWindow" TypeToControl "Edit", "&Ref : Edit", "{ExtHome}{Shift {ExtEnd}}{ExtDelete}" Endif 17. The event structure to respond to the error message is now complete. 18. Change the name of the data file from AddCars.csv to ErrorCar.csv, run the script and review the log. Points Learned Checking for more than one event Use of UserCheck() Use of the “If” statement to control the flow of a script Automating the entry of data into an application 117 Exercise 16B: Testing for Valid and Invalid Data Input Objective n n To build a script that will cater to more than one situation or event Introduce the Usercheck() command Notes: - Instructor will supply the test data file person2.csv Instructions Step Action 1. Load the script from exercise 15B and save as EX16B. 2. Modify the script so it references the test data file named “c:\testdata\person2.csv”. Insert this statement as the first statement in the Function Main. 3. Screen Testdata (“c:\testdata\person2.csv”) See the example to the right. Force the Testbed application to generate an error message by navigating testbed to the Customer Master Basic Data screen and entering a customer. In the Cash Code field enter an alpha character. 4. Press the “F1” to generate the message “Field must be numeric”. Create a screen event to wait for this message. 5. Modify the script to wait for either a valid or an invalid message. Attach "Testbed for Windows V1.00 Connected MainWindow" Type "{F1}" Wait( 30 , 'for any' , "Record Update", "Invalid Record" ) See an example to the right 119 6. Add the commands to determine which of the If event ("Record Update") = 1 messages was generated and insert a Usercheck("Record Update", 1, "Record “Usercheck” to output the appropriate message. Validated") Endif See an example to the right 7. Run the script to verify it works correctly. Points Learned Checking for more than one event Use of Usercheck() statement Using the “Any” syntax in a Wait statement 120 If event ("Invalid Record") = 1 Usercheck("Record Update", 0, "Record not Validated") Exercise 17A: Capturing Data From QADemo Objective To build a script which captures data from the screen and write the info to the log Notes: Use Version 2 of QADemo Instructions Step Action 1. Open EX13A and save as EX17A. This will utilize the Functions created in EX13A. Screen Manually start up version 2 of QADemo and close the Main Options window. 2. Switch Learn ON using {Control L } or select the Record button. 3. Select the File|Main Options menu option. Navigate the application to the Add Car window by selecting Add Car on the New listbox. Press the OK button. 4. Fill in the data on this screen as follows: Field Data Ref ---------------------Car100{Tab} Make-------------------Make{Tab} Engine size-----------V8{Tab} Year--------------------98{Tab} Doors-------------------4{Tab} Color--------------------Blue {Tab} Sale Price-------------1000{Tab} Deal Discount--------5{Tab} Quantity----------------1{Tab} 5. Press the {Alt{F10}} to stop learning the script. 121 6. Use the Command wizard to insert a “Capture” command. Press Next. 7. Press the Identify button. 8. Put the cursor on the “Dealer Price” edit field and click the left mouse button. The Attach name for the “Dealer Price” edit field is captured. 9. Press the Next Button. 10. Select both the options. Press the Next button. 122 11. Press the Paste Button. 12. Review the line of code added by the command wizard. 13. Start learning the script again by pressing the {Control L} keys. Press the Close button. 14. 15. 16. Stop learning the Script by pressing the {Alt {F10}} keys. Review the code. 123 17. 18. Add "If … Else if ret = "950" Endif" logic after the UserCheck("Dealer Price",1,"The Dealer price was calculated Capture command to correctly.") test the amount else captured for a pass or UserCheck("Dealer Price",0,"The Dealer price was not calculated fail condition. correctly.") Use the UserCheck Logcomment("The expected value was 950") and LogComments to Logcomment("The actual value was >"+ ret +"<") log the expected and endif actual values for the calculation. Run the script saving it as EX17A. Review the Log file. Change Sale price to 1100 and re-run script. Note the LogComment under Command Detail in the log. Points Learned Capturing data from an application Using the LogComment and Capturebox statement 124 Exercise 17B: Capturing Data From Testbed Objective n n n To build a script that will capture from a screen using the Capturebox() command To compare the data from the data file with the information in the system Using string manipulation commands Notes: - Instructor will supply the test data file contact.csv Instructions Step 1. 2. 3. 4. Action Load the script from exercise 16B and save as EX17B. Modify the script so it references the test data file named “c:\testdata\contact.csv”. Insert this statement as the first statement in the Function Main. See the example to the right. Modify the script by deleting the following portion of the script as indicated in steps 3 and 4. Excerpts from a working script are shown at the right. From the statement: ;start reading data file Through the statement: until TestDataCurRecord = TestDataRecordCount Screen Testdata (“c:\testdata\contact.csv”) Wait(30, "", "mastermaint") ; ;start reading data file ; Repeat Wait(30, "", "mastermaint") until TestDataCurRecord = TestDataRecordCount Type "{Escape}" 5. Insert a “stop” command in the script as shown at the right. Run the script, when the script finishes, place QARun in learn mode and continue with step 6. Wait(30, "", "mainmenu") Type "{F1}" Wait(30, "", "mastermaint") Stop 6. Comment out the “Stop” command and learn the commands needed to navigate to the “Customer Master Credit Data Screen” Attach "Testbed for Windows V1.00 Connected MainWindow" Type "{F1}" Wait(5, "", "mastermaint") type "e{Tab}111" See an example to the right Type "{F1}" 125 7. Create a screen event that waits for the “Customer Master Credit Data Screen” to appear. 8. From this screen, capture the data in the “Contact” field using the CaptureBox() command. Use the command wizard to build this command and paste it into the script. 9. The code at the right will capture the “Contact” name from the screen, trim leading and trailing spaces, compare it with the data in the file and write a Usercheck to the log. Note: Textpanel commands are optional. They are used to make sure the data is being captured correctly. 10. Build a Repeat…Until loop that will read all the records from the data file and compare it to the information captured from the “Customer Master Credit Data Screen”. 11. Run the script to verify it works correctly. Points Learned - Capturing fields of data. - Using a data file to hold expected result - UserCheck() 126 cname = TestdataTransform("{=.+}") ret = CaptureBox( "Testbed for Windows V1.00 Connected MainWindow" , 110 , 131 , 125 , 14 ) temp_str1 = RtrimStr(ret) temp_str2 = LtrimStr( temp_str1) TextPanel( 1 , ret , 500 , 500 ) pause 1 seconds TextPanel( 1 , cname , 400 , 500 ) pause 1 seconds if cname = temp_str2 usercheck("name_check", 1, "name matches") else usercheck("name_check", 0, "no match") endif 127 Exercise 17C: Synchronizing using Autowait capabilities Objective To modify an existing script to take advantage of the autowait capabilities in QARun Introduce the following new commands: Replay.Autowait Replay.ActionKeys Whenever Notes: n n Know where the “busy” indicator appears on the application window Identify the action keys required by the application (F1, F2, etc.) Instructions Step Action 1. Load the script from exercise 15B and save as EX17C. 2. Insert “stop” command as shown 3. Place the cursor on the line following the “TestData” command. Screen Attach "Testbed for Windows V1.00 MainWindow" Size 600, 411 Move 66, 66 MenuSelect "Session~Connect..." Wait(30, "", "userid") STOP Function Main ; Remove the comment below to "Enable" error handling ; On Error Call OnErrorHandler CopyFile( "c:\testbed\testbed.sav" , "c:\testbed\testbed.dat" ) TestData( "c:\testbed\person1.csv" ) 4. Using the command wizard, begin building the Replay.ActionKey command 129 5. Type in the list of action keys. Action keys are the keys the application uses to move between screens and fields. 6. 7. 8. Use the command wizard to insert a “Replay.autowait” command, autowait value = 30. Build a “Whenever” command with the following information: Event Name = “ActionKey” Function = hit_actionkey After the function main, create a function called “hit_actionkey” Function hit_actionkey End Function ; hit_actionkey 9. Inside the “hit_actionkey” function, create a screen event that waits for the busy indicator to NOT be present. Name this event “busy_indicator”. 10. Click on the identify button to identify the main window of the Testbed application 130 11. Select the “Use Rectangle” and “Not Found” options 12. Capture the area on the Testbed window where the busy indicator is located. 13. Type “X SYSTEM” as shown at the right. Press the “Finish” button 14. Insert as a “Wait” event. The resulting function will look something like this: Function hit_actionkey Wait(30, "", "busy_indicator") End Function ; hit actionkey 15. Comment out all of the “wait” statements except: the first one that waits for “Userid” the one that wait for “Record Updated” 16. Run the script to verify it works correctly. Attach "Testbed for Windows V1.00 MainWindow" Size 600, 411 Move 66, 66 MenuSelect "Session~Connect..." Wait(30, "", "userid") Wait(30, "", "Record Update") 131 Exercise 18: Using PromptBox(), MessageBOX() & TextPanel() Objective - To create a Promptbox and Messagebox using the command wizard - Simple interaction with the user Notes: Return codes for the Messagebox are documented in the on-line help Instructions Step Action 1. Create a new script (using the New Button or File|New and select Script). 2. Find the MessageBox() option in the Commands column. Screen Select the command and press the Next button. 3. In the Title field, add the sentence… Missing Password In the Message Field, add the sentence… Is the password recorded in the script? Press the Next button. 4. Select the yesno option in the Buttons list. This will cause two buttons to be displayed on the Messagebox. Select the default2 option in the Default Button list. This will cause the second of the two buttons to be the default button. Press the Next button. 133 5. Select the question option in the Icon list. This will display a question mark icon on the Messagebox. Press the Next button. The window will display the syntax of the command. Press the Paste command. 6. The command is inserted into the script. Run the script and save the script as EX18A. 7. This Messagebox is displayed. Would it be useful to know which of the two buttons were pressed? 8. The number of the button selected is returned by the command. Put a variable ( Answer ) in the script to catch the button number. But, what are the button numbers for the yes and no buttons? 134 9. Select the Help|Language Help option from the menu bar. Index the help window to the Messagebox() command. Press the Display button. 10. The button numbers are documented in the middle of the help text for this command. The number for “Yes” is 6 and “No” is 7. 11. Insert an “If” statement into the code to respond to the possible button values. i.e. Yes = 6 and No = 7. 135 12. If the yes button is pressed, it means the password is in the script and no further action is required. Insert a textpanel command in the if structure that will respond to the yes button being pressed. This will indicate the password is already in the script. 13. Follow it with a sleep command so you will have time to see the textpanel in the upper left corner of the monitor. If the No button was pressed, it would be nice to be able to get the password from the user. This can be done by using a Promptbox. Position the cursor between the if and the endif of the no if structure. Then start the command wizard. Select the Promptbox option in the command list. Press the Next button. 14. 136 Enter information as shown at the right and press the Next button. 15. The window location window is displayed. No coordinates are needed for this script so… Press the Next button. This is the structure of the command that will be loaded. Press the Paste button. 16. The following command is pasted into the script. ret = PromptBox( "Enter the Missing Password." , "Please enter the missing password for this script." , Password ) The variable "ret" contains the button number of the button selected to clear the promptbox. 17. 18. The Password entry is the variable used to store the value entered into the promptbox. The password is now available for use. Perhaps a line of code should be used to show the password was captured. Use the same TextPanel window to display the password. Also, use the sleep command to allow some time to read the textpanel. 137 19. Run the script. When the messagebox is displayed, select the No button to make the promptbox display. 20. When the promptbox is displayed, enter a password into the edit field. Press the OK button. 21. Notice the Textpanel has displayed the password as it was entered in the promptbox. Points Learned The use of Promptbox, Textpanel and MessageBox commands 138 Exercise 19A: Creating a Dialog Box Objective - To build a dialog box that prompts for userid and password and passes that information to an application Notes: None Instructions Step 1. Create a new script by pressing the Editor toolbar button. 2. Position the cursor to the correct spot in the script. 3. 4. Screen Press the Dialog toolbar button to create a new dialog window. The Browse Dialogs window will be displayed. Press the New Button. 139 5. The Dialog maintenance window will appear. A dialog window can be created which will contain a varied set of window objects. 6. Press the Static toolbar button to create two Static text objects. Double click on the first static text field. 7. 8. The Control Properties window will display with the properties that pertain to the type of object select. Enter the following information into the Caption field: User ID: Press the OK Button. 140 9. The Dialog maintenance window will reappear. Double click on the second Static text field. In the Control Properties Caption edit field enter the following information: Password : Press the OK Button. 10. The two new static fields are now displayed. Resize the objects if the complete text is not displayed. 11. Click on the Edit Control toolbar button and create two new edit fields. When the two edit fields are on the dialog window, double click on the first edit field. 12. 141 13. When the Control Properties window appears, change the Name edit field to the following information: UserID Edit Press the OK button. 14. Double click on the Second Edit object and change the Name Edit field to the following information: Password Edit 15. Click on the Edit Properties tab and select the Password checkbox. Press the OK Button. 16. The edit fields are now complete. The dialog window will need two buttons. 142 17. Click on the Push Button toolbar button to create two new Buttons. 18. Click on the first button to change its Properties. 19. When the Control Properties window appears, change the following information: Name: Ok Button Caption: &OK Press the OK button. 20. Double click on the second button and change its properties to the following: Name: Cancel Button Caption: &Cancel Press the OK button. 143 21. The dialog in now compete. Close the Dialog Window. 22. Save the dialog with the name startup. 23. The script will be displayed. Notice the Dialog command is displayed. The information loaded in the Dialog window will be returned to the script in an array. The array is automatically pasted into the script, above the dialog command. 144 24. Uncomment the Array value used to store the User name and assign it the string value of “Full Name”. This will preload user id edit field on the dialog window with "Full Name". 25. Modify the script to respond to the OK button on the dialog window. Insert an “If” structure to check if the Array value for the OK Button is equal to one. 26. Set up the “If” to display a Messagebox for the User id and the password. 27. Run the script and save it as EX19A. When the Dialog is displayed, tab to the Password edit field and enter a password ( i.e The password ). Press the OK Button. 145 28. The message box will display the password that was entered into the dialog window. 29. Add steps to pass UID and PWD to the QADemo application in version 2. Points Learned Using the dialog editor Passing information from the dialog to an application 146 Exercise 19B: Creating a Dialog Box Objective - To build a dialog box that prompts for userid and password and passes that information to an application Notes: None Instructions Step Action 1. Create a new script by pressing the Editor toolbar button. 2. Position the cursor to the correct spot in the script. 3. 4. Screen Press the Dialog toolbar button to create a new dialog window. The Browse Dialogs window will be displayed. Press the New Button. 147 5. The Dialog maintenance window will appear. A dialog window can be created which will contain a rich set of window objects. 6. Press the static toolbar button to create two Static text objects. Double click on the first static field. 7. 8. The Control Properties window will display with the properties that pertain to the type of object selected. Enter the following information into the Caption field: User ID: Press the OK Button. 148 9. The Dialog maintenance window will appear. Double click on the second Static text field. In the Control Properties Caption edit field enter the following information: Password: Press the OK button. 10. The two new static fields are now displayed. Resize the objects if the complete text is not displayed. 11. Click on the Edit Control toolbar button to create two edit fields. When the two edit fields are on the dialog window, double click on the first edit field. 12. 149 13. When the Control Properties window appears, change the Name edit field to the folllowing information: USERID Edit: Press the OK button. 14. Double click on the Second Edit object and change the Name Edit field to the following information: Password Edit 15. Click on the Edit Properties tab and select the Password checkbox. Press the OK button. 16. The edit fields are now complete. The dialog window will need two buttons. 150 17. 18. 19. Click on the Push Button toolbar button to create two buttons. Click on the first button to change its properties. When the Control Properties window appears, change the following information: Name: OK button Caption :&OK Press the OK button. 20. Double click on the second button and change its properties to the following: Name: Cancel Button Caption: &Cancel Press the OK button. 151 21. The dialog is now complete. Close the Dialog Window. 22. Save the dialog with the name Startup. 23. The script will be displayed. Notice the Dialog command is displayed. The information loaded in the Dialog window will be returned to the script array. The array is automatically loaded into the script, above the dialog command. 152 24. Uncomment the element in the array that contains the User Name and assign it the string value of “Full Name”. This will pre-load user id edit field on the dialog window. 25. Modify the script to respond to the OK button on the dialog window. Insert an If structure to check if the array value for the OK button is equal to one. 26. Set up the If structure to display a messagebox to display the User id and the password. 27. Run the script and save it as EX19B. When the dialog is displayed, tab to the Password edit field and enter a password ( i.e. the Password) Press the OK button. 153 28. The message box will display the password that was entered into the dialog window. 29. Open script EX17B and insert the QARUN DIALOG by selecting Insert|Dialogs from the menu. 30. Modify the Script. Locate the statements in the script where the Userid and Password information is hardcoded in the script. Replace this information (l dtl and Passdtl) with appropriate element from the array that defines the dialog control. See example to the right. Run the script saving as EX19B. 31. TYPE STARTUP_CONTROLS[“EDIT1”]{TAB}STA RTUP_CONTROLS[“EDIT2”]{RETURN} Points Learned Using the dialog editor Passing information from the dialog to an application 154 Exercise 20A: Date Aging Objective To build a script which uses Date Aging Functionality Notes: Use Version 2 of QADemo Instructions Step Action 1. Create a new script . 2. Switch Learn ON using {Control L } or select the Record button. 3. 4. Start QADemo version 2. Select the File|Main Options menu option. Screen Navigate the application to the Add Car window by selecting Add Car on the New listbox. Press the OK button. 5. Fill in the data on this screen as follows: Field Data Ref ---------------------Car100{Tab} Make-------------------Make{Tab} Engine size-----------V8{Tab} 6. Press Ctrl+F5 to bring up the CreateDate function. Highlight “+0” and use the up arrow keys on the keyboard to age the date by 3 years. 155 7. 8. Press the “Ok” button. Note that QARun will fill in the “Year” field with todays date and insert the lines into the script as shown on the right. Tab to the “Doors” field and enter the data as shown. 9. Press the “Add” and “Close” button to return to the Main window. 10. Select the File|Main Options menu option. Navigate the application to the Inquire window by selecting Inquire on the New listbox and press the OK button. 11. 156 Press the Refresh button on the Inquire screen DateRet = CreateDate("22 Jul 1998","DD Mmm YYYY","aged","today ") Attach "Add Car ChildWindow" TypeToControl "Edit", "&Year :", DateRet 12. Hightlight the car that was added and double click on it 13. The “Car Details” window will be displayed, 14. Use the “Insert Check” hotkey (Alt-F8) to create a text check on the “Year” field. Identify the "year" edit field. Then click on the "Include" tab and the "new" button. 15. Click on the “Any valid date” radio button and check the “Date is age” checkbox. 157 16. QARun will display the screen as shown on the right. 17. Click on the “Years” checkbox and highlight “+0”. Use the up arrow keys on the keyboard to age the year by 3 18. 19. 20. Press the “OK” button Close the “Car Details” window. From the “Inquire” screen, delete the car just entered. Close the “Inquire” screen and close QADemo. Stop learning Run the script, saving it as EX20A Create a new Runtime environment using a future date as a "today" value and rerun the script. Does the check still pass? 21. 22. 23. 24. Points Learned Introduction to using the Age Date facility. 158