330 likes | 392 Views
Req0005-8. Implementation of Req0005, Req0006, Req0007 and Req0008. TIP. Fr Project staff have made an improvement to the presentations. Whenever you see QTP code, right click the left bottom part of the presentation and do the following :. 1. 2. Click. Topics covered.
E N D
Req0005-8 Implementation of Req0005, Req0006, Req0007 and Req0008 Dani Vainstein & Monika Arora Gautam
TIP • Fr Project staff have made an improvement to the presentations. • Whenever you see QTP code, right click the left bottom part of the presentation and do the following : 1 2 Click Dani Vainstein & Monika Arora Gautam
Topics covered • The efficiency of the GUI layer. • Action Return Values. • Test Result Deletion Tool. Dani Vainstein & Monika Arora Gautam
Req0005 • The password must be at least 4 characters long. • Less than 4 characters will trigger an exclamation popup message “Password must be at least 4 characters long.” Dani Vainstein & Monika Arora Gautam
Req0005 – Scenario Details • Step 1 – Type agent name, more than 3 characters long. • Step 2 – Type a password less than 4 characters long. • Step 3 – Press OK • Step 4 • A) Popup dialog is displayed. • B) Popup title : Flight Reservations • C) Message type : Exclamation • D) Message text “Password must be at least 4 characters long’ • Step 5 – Close the dialog. Dani Vainstein & Monika Arora Gautam
displayed=true Ispopup = true Req0005 – Overview Details Title = Flight Reservations Icon = Exclamation text = Password must be at least 4 characters long. Dani Vainstein & Monika Arora Gautam
Requirement - Req0005 • What are the differences between Req0004 and Req0005? • Nothing. The test process is the same, the only difference is that we are testing different field and different message. Dani Vainstein & Monika Arora Gautam
Implementing Business Req0005 • Open the test busLogin, action busLoginMng • Menu : File Open Test Dani Vainstein & Monika Arora Gautam
Creating a new step • Add a new step case “req0005” ( remember to write the string in lower case ) Req0005 Dani Vainstein & Monika Arora Gautam
Implementing Business Req0005 Case"req0005" GDictionary.Add"AGENT_NAME", "advancedQTP" GDictionary.Add"PASSWORD", vbNullString : GDictionary.Add"OK", vbNullString For i = 1 To 3 GDictionary( "PASSWORD" ) = String( i, "a" ) Reporter.ReportEvent micInfo, "Req0005", "String length is " & i RunAction "guiLogin [guiLogin]", oneIteration, "Login" ' ** Req0005 - 'Password must be at least 4 characters long.' RunAction "CheckDialog [guiLogin]", oneIteration, "MSG0003" Next • Do not forget to update FR.xls with following data : • MSG0003 | Password must be at least 4 characters long | Flight Reservations | 1 Dani Vainstein & Monika Arora Gautam
Automation FR LIB RA BL GL RS DOC DAT SETTING Req0005 TESTS RES BATCH ENV Implementing Test Req0005 • Create a new Test “Req0005” • Make the same steps as we did for Req0004 Dani Vainstein & Monika Arora Gautam
Modifying the Test • Change the header. '*********************************************************************** '@Author : advancedQTP '@Date Created : <ddd MMM dd, yyyy> '@QTP Version : 9.2 '@Description : The test covers the requirement Req0005 '@Input Parameter : None. '@Out Parameter : None. '@Ass. Libraries : FR.vbs '@Addins : ActiveX '@Modifications : <#n By <Name>, Date: <dd-mmm-yyyy>> (Later modification on top) ' <#n-1 By <Name>, Date: <dd-mmm-yyyy> '*********************************************************************** Dani Vainstein & Monika Arora Gautam
Modifying the Test Settings and call to Business action • Select Menu Settings Add Description RunAction "busLoginMng [busLogin]", oneIteration, "Req0005" Dani Vainstein & Monika Arora Gautam
Req0006 and Req0007 Dani Vainstein & Monika Arora Gautam
Implementing Business Req0006 and Req0007 Case"req0006" GDictionary.Add"AGENT_NAME", "advancedQTP" GDictionary.Add"OK", vbNullString RunAction "guiLogin [guiLogin]", oneIteration, "Login" ' ** Req0006 - 'Please enter password' RunAction "CheckDialog [guiLogin]", oneIteration, "MSG0004" Case"req0007" GDictionary.Add"AGENT_NAME", "advancedQTP" : GDictionary.Add"PASSWORD", "1234" GDictionary.Add"OK", vbNullString RunAction "guiLogin [guiLogin]", oneIteration, "Login" ' ** Req0007 - 'Incorrect password. Please try again' RunAction "CheckDialog [guiLogin]", oneIteration, "MSG0005" Dani Vainstein & Monika Arora Gautam
Updating Data Source • And … don’t forget to add the new messages to the data source. Dani Vainstein & Monika Arora Gautam
Req0008 • When we press on Cancel button, the application should be closed. • We will use the same “login” process used with previous tests ( req0006,7 ) • In addition to this, we will add a new CASE in guiLogin, that verify whether “Login” dialog exists or not. • Lastly, we will use the action return value. Dani Vainstein & Monika Arora Gautam
Implementing Business Req0008 Case"req0008" GDictionary.Add"CANCEL", vbNullString RunAction "guiLogin [guiLogin]", oneIteration, "Login" ' ** Req0008 - 'Application canceled' bExist = RunAction( "guiLogin [guiLogin]", oneIteration, "LoginExists" ) If Not bExist Then Reporter.ReportEvent micPass, "Req0008", "Dialog not exists." Else Reporter.ReportEvent micFail, "Req0008", "Dialog exists." EndIf • bExist holds the return value of the guiLogin reusable-action. • Whenever a reusable-action is called using a return value, the call must be enclosed within parenthesis. Dani Vainstein & Monika Arora Gautam
Variables Declaration • In order to avoid from receiving runtime errors, always declare the new variables. Declaring Variables Using Dim keyword Dani Vainstein & Monika Arora Gautam
Modifying guiLogin Case"loginexists" bExist = Dialog( "Login" ).Exist( 1 ) ExitAction( bExist ) Dani Vainstein & Monika Arora Gautam
Create Tests Req0006 to Req0008 • Please follow the steps described earlier, and create Test Req0006, Req0007 and Req0008 Dani Vainstein & Monika Arora Gautam
Adding Tests to the MTM • Excel file must be closed every time you run a script or/and a .mtm or .mtb batch file. Dani Vainstein & Monika Arora Gautam
Results Dani Vainstein & Monika Arora Gautam
Deleting old Results • After a while, when you run tests or test batch several times, results folders will start to accumulate. • Results Folders volume can be very big, now that is a serious problem, but sometimes you don’t want to keep run history. Results Folders Dani Vainstein & Monika Arora Gautam
Test Results Deletion Tool • Every test saves history of run. • Manually you can go to each folder and remove the Resx Folder, or you can write a script. • This can be a frustrating job. • Let me introduce you to the “Test Results Deletion Tool” Dani Vainstein & Monika Arora Gautam
Test Results Deletion Tool Dani Vainstein & Monika Arora Gautam
Test Results Deletion Tool Dani Vainstein & Monika Arora Gautam
Test Results Deletion Tool Dani Vainstein & Monika Arora Gautam
Full information on tests That were found and disk Available space You can sort tests by Date, size, name and time Select all items, Or those that You want to remove Test Results Deletion Tool Include test results found in subfolders Dani Vainstein & Monika Arora Gautam
Test Results Deletion Tool • If you run your tests using MTM, don’t forget to remove old reports under REP folder. Dani Vainstein & Monika Arora Gautam
Summary • We learned how to use the Global Dictionary as a controller for the GUI layer • We learned how to use already implemented functionality for new tests. • We learned how to use the Test Results Deletion Tool. Dani Vainstein & Monika Arora Gautam
What’s Next? • Implementing Req0009 • Adding an environment variable manually. • Creating a regular “successful login” process. • Usage of global dictionary. • Adding tests to MTM. • Using the action return value. Dani Vainstein & Monika Arora Gautam
Make sure to visit us for: Tutorials Articles Projects And much more @ www.AdvancedQTP.com 33 Dani Vainstein & Monika Arora Gautam