360 likes | 433 Views
Req0009. Implementation of Req0009. Topics covered. Implementing Req0009 Manually adding an environment variable. Creating a regular “successful login” process. Usage of global dictionary. Adding tests to MTM. Using the action return value. Requirement - Req0009.
E N D
Req0009 Implementation of Req0009 Dani Vainstein & Monika Arora Gautam
Topics covered • Implementing Req0009 • Manually adding an environment variable. • Creating a regular “successful login” process. • Usage of global dictionary. • Adding tests to MTM. • Using the action return value. Dani Vainstein & Monika Arora Gautam
Requirement - Req0009 Dani Vainstein & Monika Arora Gautam
Req0009 – Scenario Details • Step 1 – Type a valid “Agent Name”, should be more than 3 characters long. • Step 2 – Type an invalid password • Leave it blank ( Zero Length ) • Less than 4 characters. • Incorrect password. • Step 3 – Press OK and close the dialog. • Return To Step 2. • Step 4 – again in the 4th attempt enter invalid password. • A) Popup dialog is displayed. • B) Popup title : Flight Reservations • C) Message type : Exclamation • D) Message text “Login unsuccessful. Please try again later.” • Step 5 – Press “OK” and close the dialog. • Application close itself. Dani Vainstein & Monika Arora Gautam
Displayed And Popup Req0009 – Overview Details Title = Flight Reservations Icon = Exclamation text = Agent name must be at least 4 characters long. Dani Vainstein & Monika Arora Gautam
InvokeApp Function Passed Start Set Agent Name Set Password Press OK Failed Login Exist? Report micPass Report micFail End Press OK Req0009 – Process Design x4 4th iteration No Yes Dani Vainstein & Monika Arora Gautam
Implementing Business Req0008 • Open the test busLogin, action busLoginMng • Menu : File Open Test Dani Vainstein & Monika Arora Gautam
Creating a new step • Add a new step case “req0009” ( remember to write the string in lower case ) req0009 Dani Vainstein & Monika Arora Gautam
Implementing Business Req0009 • We want to set an “Agent Name”, a “Password” and press OK. • We’ll ignore the error message until the last iteration (as we’re testing the final message) • For this requirement we are not going to implementing a process that checks if an error message exists, in this case we are ignoring error messages that relate to invalid password and continuing by pressing the “OK” button on error message popup/s. • Similarly we will not check the icon type, message and the title for popup messages that relate to invalid password. GDictionary.Add "OK", vbNullString : GDictionary.Add"AGENT_NAME", "advancedQTP" GDictionary.Add"IGNORE_ERROR", "OK" Dani Vainstein & Monika Arora Gautam
Implementing Business Req0009 • We have a “Login” process in guiLogin, which we will modify. • We will add a new keyword flag “IGNORE_ERROR”. • If this keyword exists, it will check if an error message pops up and it will press a button. • Which button? GDictionary( “IGNORE_ERROR” ) button can be “OK” or “Cancel”. GDictionary.Add "OK", vbNullString : GDictionary.Add "AGENT_NAME", "advancedQTP" GDictionary.Add "IGNORE_ERROR", "OK" Dani Vainstein & Monika Arora Gautam
Implementing Business Req0009 • We are going to use a loop that iterates 4 times exactly. • The For…Next loop is an excellent choice for this task. • We are going to use the same String function, as we did in Req0005. • But, we want to generate all types of errors • Empty Password. • Incomplete Password ( less than 4 characters long ) • Incorrect Password. • We will take advantage of the For…Next loop and String function. • String( 0, “P” ) will return an Empty String. • The loop will iterate from 0 ( zero ) to 3 ( 4 times ) Dani Vainstein & Monika Arora Gautam
Implementing Business Req0009 • In the first loop String function will generate an empty string ( 2 * 0, “P” ) • In the second loop String function will generate an incomplete password ( 2 * 1, “P” ) • The third and fourth loops will generate an incorrect password. • Now, we are ready to call the “Login” process For i = 0 To 3 GDictionary( "PASSWORD" ) = String( 2 * i, "P" ) RunAction "guiLogin [guiLogin]", oneIteration, "Login" Next Dani Vainstein & Monika Arora Gautam
Implementing Business Req0009 • We need to wait till last iteration ( i=3 ) • The Last iteration will check the displayed error message(“Login unsuccessful. Please try again later” ) • At last, we will check that the “Login” dialog is closed. as we did in Req0008. If i = 3 Then RunAction "CheckDialog [guiLogin]", oneIteration, "MSG0006" bExist = RunAction( "guiLogin [guiLogin]", oneIteration, "DialogExists" ) IfNot bExist Then Reporter.ReportEvent micPass, "Req0009", "Dialog not exists." Else Reporter.ReportEvent micFail, "Req0009", "Dialog exists." EndIf EndIf Dani Vainstein & Monika Arora Gautam
Business Req0009 – Final Look Dani Vainstein & Monika Arora Gautam
Modifying guiLogin - “Login” Process • The location of amended code inside case “login” is very important. It must follow the business flow. • The code must be implemented after pressing OK, not before. • Don’t forget to declare a variable buttonName ( Dim Statement ) 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 EndIf End If 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
Create Tests Req0009 • Create Test Req0009 as explained in previous presentations. • This is a copy of action look at req0004 for complete information how to do it if you have forgotten. (08 Req0004_v1.pps) Dani Vainstein & Monika Arora Gautam
Adding Tests to the MTM • Excel file must be close every time you run a script or/and a .mtm or .mtb batch file Dani Vainstein & Monika Arora Gautam
Finalizing busLogin • We have one more task, just before “closing” the busLoginMng reusable action, in busLogin we need to implement the following features: • A regular successful Login process. • Going forward, we may want the “Agent Name” to be flexible and configurable, since password will always remain same for this application. • The next few slides will implement all these features. Dani Vainstein & Monika Arora Gautam
Automation FR LIB RA BL GL RS DOC DAT SETTING TESTS RES BATCH ENV Adding the “Agent Name” to environment file • Open the FR.xml file for editing in notepad, or another XML editor. FR.xml Dani Vainstein & Monika Arora Gautam
Inserting a New Variable and Value • Add the Variable AGENT_NAME with a value that includes at least 4 characters. • Save the file. Dani Vainstein & Monika Arora Gautam
Regular “Login” business Action • For a successful business login action is required an agent name, a valid password, click OK and verifies that the “Main” window is displayed. • During the run-time if any error occurred then there is no point to continue testing any further. Case "login" GDictionary.Add"AGENT_NAME", Environment( "AGENT_NAME" ) GDictionary.Add"PASSWORD", "Mercury" : GDictionary.Add "OK", vbNullString GDictionary.Add "MAIN", vbNullString RunAction "guiLogin [guiLogin]", oneIteration, "Login" If Reporter.RunStatus = micFail Then ExitTest( micFail ) Dani Vainstein & Monika Arora Gautam
busLogin – Final Look Dani Vainstein & Monika Arora Gautam
busLogin – Final Look Dani Vainstein & Monika Arora Gautam
busLogin – Final Look Dani Vainstein & Monika Arora Gautam
busLogin[busLoginMng] – Final Look Dani Vainstein & Monika Arora Gautam
guiLogin – Final Look Dani Vainstein & Monika Arora Gautam
guiLogin – Final Look Dani Vainstein & Monika Arora Gautam
guiLogin – Final Look Dani Vainstein & Monika Arora Gautam
FR.vbs – Final Look Dani Vainstein & Monika Arora Gautam
FR.vbs – Final Look Dani Vainstein & Monika Arora Gautam
FR.vbs – Final Look Dani Vainstein & Monika Arora Gautam
Summary • We learned how to use the Global Dictionary as a set of instructions and data usage for the GUI layer • We learned how to use already implemented functionality for new tests. Dani Vainstein & Monika Arora Gautam
What’s Next? • Debugging Your Scripts. • Watch Expressions. • Debug Viewer. • Watch Variables. • Run-time Commands. • Debug Toolbar. • Debug Options. • Breakpoints. • Analyzing Test Results. • Filtering Messages. • Exporting to html. Dani Vainstein & Monika Arora Gautam
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. • Richi Sharma from USA, New Jersey. • Sanjeev Mathur from India, Noida. Dani Vainstein & Monika Arora Gautam
Make sure to visit us for: Tutorials Articles Projects And much more @ www.AdvancedQTP.com 36 Dani Vainstein & Monika Arora Gautam