Download presentation
Presentation is loading. Please wait.
1
Requirement Req0004 Implementation of Req0004
Dani Vainstein & Monika Arora Gautam
2
Topics covered Using The Global Dictionary. Using Loops.
Inserting a call to a “copy” of an existing action. Deleting an existing action. Dani Vainstein & Monika Arora Gautam
3
Before You Start… Before starting the presentation, read about the following topics in QTP help. Dictionary Object. Item property Exist Method. Remove/RemoveAll/Add Method. String Function. Dani Vainstein & Monika Arora Gautam
4
Requirement - Req0004 Dani Vainstein & Monika Arora Gautam
5
Req0004 – Scenario Details Step 1 – Type agent name, less than 4 characters long. Step 2 – Type a password Step 3 – Press OK Step 4 A) Popup dialog is displayed. B) Popup title : Flight Reservations C) Message type : Exclamation D) Message text "Agent name must be at least 4 characters long." Step 5 – Close the Flight Reservations dialog. Dani Vainstein & Monika Arora Gautam
6
Title = Flight Reservations
Req0004 – Overview Details Title = Flight Reservations Icon = Exclamation Displayed = true Ispopup = true text = Agent name must be at least 4 characters long. Dani Vainstein & Monika Arora Gautam
7
Process Design – Req0004 InvokeApp Function
No Dialog Login Exists? ExitTest Yes Report micFail Invoke App Start InvokeApp Function x3 Type Agent Name Type Password 1 Press OK Dani Vainstein & Monika Arora Gautam
8
Process Design – Req0004 Dani Vainstein & Monika Arora Gautam Yes
No Req0004a? Yes Report micFail End Req0004b Passed Failed micPass Req0004d FR.Press OK Load messages Repository 1 Dani Vainstein & Monika Arora Gautam
9
Process Design – Req0004 Dani Vainstein & Monika Arora Gautam Yes
No Req0004a? Yes Report micFail End Req0004b Passed Failed micPass Req0004d FR.Press OK Load messages Repository 1 Dani Vainstein & Monika Arora Gautam
10
Process Design – Req0004 Dani Vainstein & Monika Arora Gautam Yes
No Req0004a? Yes Report micFail End Req0004b Passed Failed micPass Req0004d FR.Press OK Load messages Repository 1 Dani Vainstein & Monika Arora Gautam
11
Process Design – Req0004 First we need a regular invoke application process ( Already done in InvokeApp function ) Then we need to verify that the invoke application. process was successful, before accessing the Dialog. If the process fails it means that the login failed and there’s no point to continue testing. The Req0004 process starts with the first step, enter “Agent Name” value, enter “Password” value, and press the “OK” button. Dani Vainstein & Monika Arora Gautam
12
Process Design – Req0004 After pressing “OK” button in the login dialog we need to check if another dialog was displayed and that dialog is “ispopupwindow=true” (Req0004a). Load the messages repository. Test requirements Req0004b through Req0004d Close the Flight Reservations popup. The process will iterate 3 times against three different “Agent Name” ( value length would be 1, 2 and 3 characters ) Dani Vainstein & Monika Arora Gautam
13
Implementing a Generic Login process
Open the guiLogin test. Dani Vainstein & Monika Arora Gautam
14
Implementing a Generic Login process
Req0004 leads us to implement a full generic “Login” process. Dani Vainstein & Monika Arora Gautam
15
Design a full “Login” Process
Start Agent Name? Yes Set Agent Name Password? Yes Set Password OK? Yes Click OK Cancel? Yes Click Cancel Main? Yes Main Exist? Report micFail No End Yes ExitTest Dani Vainstein & Monika Arora Gautam
16
Design a full “Login” Process
If the key “AGENT_NAME” Name exists, Set agent name to the key’s value. If the key “PASSWORD’ exists, Set password to the key’s value. If the key “OK” exists, Click OK. If the key “CANCEL” exists, Click Cancel. If the key “MAIN” exists, then check if the main window is displayed. When the key does not exists, the step is skipped for the specific case. Dani Vainstein & Monika Arora Gautam
17
Implementing a Login process (guiLogin)
Case "login" If GDictionary.Exists( "AGENT_NAME" ) Then Dialog( "Login" ).WinEdit( "AgentName" ).Set GDictionary( "AGENT_NAME" ) End If If GDictionary.Exists( "PASSWORD" ) Then Dialog( "Login" ).WinEdit( "Password" ).Set GDictionary( "PASSWORD" ) If GDictionary.Exists( "OK" ) Then Dialog( "Login" ).WinButton( "OK" ).Click If GDictionary.Exists( "CANCEL" ) Then Dialog( "Login" ).WinButton( "Cancel" ).Click Case "login" If GDictionary.Exists( "AGENT_NAME" ) Then Dialog( "Login" ).WinEdit( "AgentName" ).Set GDictionary( "AGENT_NAME" ) End If If GDictionary.Exists( "PASSWORD" ) Then Dialog( "Login" ).WinEdit( "Password" ).Set GDictionary( "PASSWORD" ) If GDictionary.Exists( "OK" ) Then Dialog( "Login" ).WinButton( "OK" ).Click If GDictionary.Exists( "CANCEL" ) Then Dialog( "Login" ).WinButton( "Cancel" ).Click Dani Vainstein & Monika Arora Gautam
18
Implementing a Login process (guiLogin)
If GDictionary.Exists( "MAIN" ) Then If Not Window( "regexpwndtitle:=Flight Reservation" ).Exist( 5 ) Then msg = "Dialog 'Flight Reservation' is not displayed after 5 seconds." Reporter.ReportEvent micFail, "ApplicationException", msg ExitTest( micFail ) End If If GDictionary.Exists( "MAIN" ) Then If Not Window( "regexpwndtitle:=Flight Reservation" ).Exist( 5 ) Then msg = "Dialog 'Flight Reservation' is not displayed after 5 seconds." Reporter.ReportEvent micFail, "ApplicationException", msg ExitTest( micFail ) End If Dani Vainstein & Monika Arora Gautam
19
Modifications Since we have implemented a process that handles all the functionality in the “Login” dialog, it will be better to remove the Case “ok” option. Sometimes you’ll find, that you need to improve and/or modify your scripts, for better modularity. This is a normal process, also remember to fix the dependencies ( i.e. calling actions in the business layer ) Even if you have planned your steps very carefully, there are chances that a script might change due to addition of new features or removal of existing ones in applications ( maintenance ) Case "ok" : Dialog( "Login" ).WinButton( "OK" ).Click Dani Vainstein & Monika Arora Gautam
20
Login process – Final Look
Case "login" If GDictionary.Exists( "AGENT_NAME" ) Then Dialog( "Login" ).WinEdit( "AgentName" ).Set GDictionary( "AGENT_NAME" ) End If If GDictionary.Exists( "PASSWORD" ) Then Dialog( "Login" ).WinEdit( "Password" ).Set GDictionary( "PASSWORD" ) If GDictionary.Exists( "OK" ) Then Dialog( "Login" ).WinButton("OK").Click If GDictionary.Exists( "CANCEL" ) Then Dialog( "Login" ).WinButton("Cancel").Click If GDictionary.Exists( "MAIN" ) Then If Not Window( "regexpwndtitle:=Flight Reservation" ).Exist( 10 ) Then msg = "Dialog 'Login' is not displayed after 5 seconds." Reporter.ReportEvent micFail, "ApplicationException", msg ExitTest( micFail ) If GDictionary.Exists( "IGNORE_ERROR" ) Then If Dialog("Login").Dialog( "text:=Flight Reservations","nativeclass:=#32770" ).Exist( 1 ) Then buttonName = GDictionary( "IGNORE_ERROR" ) Dialog("Login").Dialog( "text:=Flight Reservations","nativeclass:=#32770" ).WinButton( "text:=" & buttonName ).Click Dani Vainstein & Monika Arora Gautam
21
Implementing Business Req0004
Open the test busLogin, action busLoginMng Menu : File Open Test Dani Vainstein & Monika Arora Gautam
22
Creating a new step Add a new step case “req0004” ( remember to write the string in lower case ) req0004 Dani Vainstein & Monika Arora Gautam
23
Implementing Business Req0004
Business Req0004 needs to execute 3 steps in the guiLogin module, ”login” process that we’ve just made. AGENT_NAME is started with an empty string, since that value is going to change every iteration. The PASSWORD is initialized with “MERCURY”, since the value is not going to change. OK with an empty string, because we only need to create the key, value is not relevant. The “OK” in this case acts like an instruction. Case "req0004" GDictionary.Add "AGENT_NAME", vbNullString GDictionary.Add .Add "PASSWORD", "MERCURY" : GDictionary.Add "OK", vbNullString Case "req0004" GDictionary.Add "AGENT_NAME", vbNullString GDictionary.Add "PASSWORD", "MERCURY" : GDictionary.Add "OK", vbNullString Dani Vainstein & Monika Arora Gautam
24
Implementing Business Req0004
Business Req0004 must be a loop test-case. Needs to test if 1,2 or 3 characters are entered, triggers the exclamation message. Because we know that the loop needs 3 iterations, the best method is to use a For…Next loop. Do not forget to declare the variable i, otherwise you will get a run-time error “Variable was not declared”. ( Dim i ) Case "req0004" For i = 1 To 3 Next Dani Vainstein & Monika Arora Gautam
25
Implementing Business Req0004
Case "req0004" For i = 1 To 3 GDictionary( "AGENT_NAME" ) = String( i, "a" ) Reporter.ReportEvent micInfo, "Req0004", "String length is " & i Next We will use the String function of VBScript. It returns a repeating character string of the length specified. By doing so we are also adding the key “AGENT_NAME” of the global dictionary, so that when guiLogin is invoked, all the “keys” are already set. We also adding an information message using Reporter.ReportEvent method. Dani Vainstein & Monika Arora Gautam
26
Implementing Business Req0004
RunAction "guiLogin [guiLogin]", oneIteration, "Login" ' Calling to gui process ' ** Req 'Agent name must be at least 4 characters long.' RunAction "CheckDialog [guiLogin]", oneIteration, "MSG0002" Inside the For…Next loop, the guiLogin with “Login” argument, and “CheckDialog” with “MSG0002” argument will be called. RunAction "guiLogin [guiLogin]", oneIteration, "Login" ' Calling to gui process ' ** Req 'Agent name must be at least 4 characters long.' RunAction "CheckDialog [guiLogin]", oneIteration, "MSG0002" Dani Vainstein & Monika Arora Gautam
27
busLogin – Final Look ( Req0004 )
Case "req0004" GDictionary.Add "AGENT_NAME", vbNullString GDictionary.Add "PASSWORD", "MERCURY" : GDictionary.Add "OK", vbNullString For i = 1 To 3 GDictionary( "AGENT_NAME" ) = String( i, "a" ) Reporter.ReportEvent micInfo, "Req0004", "String length is " & i RunAction "guiLogin [guiLogin]", oneIteration, "Login" ' ** Req 'Agent name must be at least 4 characters long.' RunAction "CheckDialog [guiLogin]", oneIteration, "MSG0002" Next Notice that we still have 2 external reusable actions, and 1 internal reusable action. Dani Vainstein & Monika Arora Gautam
28
Fixing Req0003 Dani Vainstein & Monika Arora Gautam Change To
Case "req0003" ' ** clicking OK RunAction "guiLogin [guiLogin]", oneIteration, "OK" ' ** Req 'Please enter agent name' RunAction "CheckDialog [guiLogin]", oneIteration, "MSG0001" Change To Case "req0003" GDictionary.Add "OK", vbNullString RunAction "guiLogin [guiLogin]", oneIteration, "Login" ' ** Req 'Please enter agent name' RunAction "CheckDialog [guiLogin]", oneIteration, "MSG0001" Case "req0003" GDictionary.Add "OK", vbNullString RunAction "guiLogin [guiLogin]", oneIteration, "Login" ' ** Req 'Please enter agent name' RunAction "CheckDialog [guiLogin]", oneIteration, "MSG0001" Dani Vainstein & Monika Arora Gautam
29
Remark You can also change the implementation of Req0002 in the same way. We are not going through this step, because we want to show you different solutions for similar issues. Dani Vainstein & Monika Arora Gautam
30
Implementing Test Req0004 We have already seen that the tests Req0001, Req0002 and Req0003 are the same. So the test Req0004 would be the same too. In fact, the test layer never changes, it is always use the same code. The differences are : Test Name Call to business action ( call to different business actions ) So the question is, why should we create a new test? The answer is: you don’t have to, But… Dani Vainstein & Monika Arora Gautam
31
Test Layer – Duplications?
In the final report, you will see different tests ran, not only one. You can define a full flow with different test names, so everyone can understand what you are testing. If you are using QC, you need to define different tests. Dani Vainstein & Monika Arora Gautam
32
Inserting a call to copy of action
LIB RA TESTS RS DOC FR DAT SETTING RES BATCH ENV Automation BL GL Create a new Test “Req0004” Req0004 Dani Vainstein & Monika Arora Gautam
33
Inserting a call to copy of action
Insert a call to copy of action Menu : Insert Call to Copy of Action Hotkey : Alt + I + A Toolbar : Dani Vainstein & Monika Arora Gautam
34
New Req0004 by inserting a call to copy of action
Edit new action properties After the current step Dani Vainstein & Monika Arora Gautam
35
Inserting a call to copy of action
Rename to Req0004 Add Description Dani Vainstein & Monika Arora Gautam
36
Modifying the Test We now have, 2 Actions; Action1 is empty, and Req0004. Select Action1 from the popup list. Remove Action1 Menu : Edit Action Delete Action After we confirmed the deletion of Action1 you will see the code of Req0003. Dani Vainstein & Monika Arora Gautam
37
Modifying the Test Change the header.
'*********************************************************************** : advancedQTP Created : <ddd MMM dd, yyyy> Version : 9.2 : The test covers the requirement Req0004 Parameter : None. Parameter : None. Libraries : FR.vbs : ActiveX : <#n By <Name>, Date: <dd-mmm-yyyy>> (Later modification on top) ' <#n-1 By <Name>, Date: <dd-mmm-yyyy> '*********************************************************************** : advancedQTP Created : <ddd MMM dd, yyyy> Version : 9.2 : The test covers the requirement Req0004 Parameter : None. Parameter : None. Libraries : FR.vbs : ActiveX : <#n By <Name>, Date: <dd-mmm-yyyy>> (Later modification on top) ' <#n-1 By <Name>, Date: <dd-mmm-yyyy> Dani Vainstein & Monika Arora Gautam
38
Modifying the Test Settings
Select Menu Settings Add Description Dani Vainstein & Monika Arora Gautam
39
Inserting a call to Existing Action
When we insert a call to copy of action, we ignore the message above. The message explains that the original Req0003/Action1, contains nested actions ( busLoginMng ) and they will not be copied. So now we need to insert the call to the business action layer. And here, you will find a surprise… Dani Vainstein & Monika Arora Gautam
40
Inserting a call to Existing Action
Take a look in the popup list of the current test. ( you will see Req0004 only ) Close the Test ( Just create a new one ) Reopen Test Req0004. Before Reopen Test After Reopen Test Dani Vainstein & Monika Arora Gautam
41
Modifying Req0004 So, the only change left, is to change the argument passed. RunAction "busLoginMng [busLogin]", oneIteration, "Req0003" Change To RunAction "busLoginMng [busLogin]", oneIteration, "Req0004" Dani Vainstein & Monika Arora Gautam
42
Updating Data Source And … don’t forget to add the new message to the message repository. Dani Vainstein & Monika Arora Gautam
43
Test Result Dani Vainstein & Monika Arora Gautam
44
Summary We learned how to use the Global Dictionary as a controller for the GUI layer We learned how to implement Loops. We learned how to Insert a call to a “copy” of an existing action. We learned how to delete an existing action. From now on, we’ll see that writing new tests will be a more easy task; since we’ve implemented a generic login process. Dani Vainstein & Monika Arora Gautam
45
What’s Next? The efficiency of the GUI layer. Action Return Values.
Test Result Deletion Tool. Dani Vainstein & Monika Arora Gautam
46
Special Thanks To Tali Hizkia from Israel, Tel-Aviv.
Paul Grossman from USA, Chicago. Dalvinder Matharu from USA, San Jose. Mike Manchester from USA, Bolivar. Joydeep Das from India, Hyderabad. Sanjeev Mathur from India, Noida. Ayyappa Koppolu from India, Pune Dani Vainstein & Monika Arora Gautam
47
Make sure to visit us for:
Tutorials Articles Projects And much more @ Dani Vainstein & Monika Arora Gautam 47
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.