Dani Vainstein & Monika Arora Gautam 1 Req0009 Implementation of Req0009.
-
Upload
bruce-copeland -
Category
Documents
-
view
217 -
download
0
Transcript of Dani Vainstein & Monika Arora Gautam 1 Req0009 Implementation of Req0009.
Dani Vainstein & Monika Arora GauDani Vainstein & Monika Arora Gautamtam
1
Req0009
Implementation of Req0009
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 2
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 GautamDani Vainstein & Monika Arora Gautam 3
Requirement - Req0009
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 4
Req0009 – Scenario Details Step 1 – Type a valid “Agent Name”, should be more than 3
characters long. Step 2 – Type an invalid password
1. Leave it blank ( Zero Length )2. Less than 4 characters.3. 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 GautamDani Vainstein & Monika Arora Gautam 5
Req0009 – Overview Details
Displayed
And Popup
text =
Agent name must be at least
4 characters long.
Icon = Exclamation
Title = Flight Reservations
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 6
Req0009 – Process Design
InvokeApp
Function
Press OK
Start
Failed
LoginExist?
Passed
ReportmicFail
End
ReportmicPass
Set Agent Name
Set Password
Press OK
YesNo
x4
4th iteration
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 7
Implementing Business Req0008 Open the test busLogin, action busLoginMng Menu : File Open Test
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 8
Creating a new step
Add a new step case “req0009” ( remember to write the string in lower case )
req0009
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 9
Implementing Business Req0009
GDictionary.Add "OK", vbNullString : GDictionary.Add "AGENT_NAME", "advancedQTP"
GDictionary.Add "IGNORE_ERROR", "OK"
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.
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 10
Implementing Business Req0009
GDictionary.Add "OK", vbNullString : GDictionary.Add "AGENT_NAME", "advancedQTP"
GDictionary.Add "IGNORE_ERROR", "OK"
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”.
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 11
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 GautamDani Vainstein & Monika Arora Gautam 12
Implementing Business Req0009
For i = 0 To 3
GDictionary( "PASSWORD" ) = String( 2 * i, "P" )
RunAction "guiLogin [guiLogin]", oneIteration, "Login"
Next
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
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 13
Implementing Business Req0009
If i = 3 Then
RunAction "CheckDialog [guiLogin]", oneIteration, "MSG0006"
bExist = RunAction( "guiLogin [guiLogin]", oneIteration, "DialogExists" )
If Not bExist Then
Reporter.ReportEvent micPass, "Req0009", "Dialog not exists."
Else
Reporter.ReportEvent micFail, "Req0009", "Dialog exists."
End If
End If
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.
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 14
Business Req0009 – Final Look
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 15
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
End If
End If
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 16
Updating Data Source
And … don’t forget to add the new messages to the data source.
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 17
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 GautamDani Vainstein & Monika Arora Gautam 18
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 GautamDani Vainstein & Monika Arora Gautam 19
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 GautamDani Vainstein & Monika Arora Gautam 20
Adding the “Agent Name” to environment file
LIB
RA
TESTS
RS
DOC
FR
DAT
SETTING
RES
BATCH
ENV
Automation
BL
GL
FR.xml
Open the FR.xml file for editing in notepad, or another XML editor.
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 21
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 GautamDani Vainstein & Monika Arora Gautam 22
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 GautamDani Vainstein & Monika Arora Gautam 23
busLogin – Final Look
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 24
busLogin – Final Look
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 25
busLogin – Final Look
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 26
busLogin[busLoginMng] – Final Look
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 27
guiLogin – Final Look
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 28
guiLogin – Final Look
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 29
guiLogin – Final Look
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 30
FR.vbs – Final Look
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 31
FR.vbs – Final Look
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 32
FR.vbs – Final Look
Dani Vainstein & Monika Arora GautamDani Vainstein & Monika Arora Gautam 33
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 GautamDani Vainstein & Monika Arora Gautam 34
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 GautamDani Vainstein & Monika Arora Gautam 35
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 GautamDani Vainstein & Monika Arora Gautam 36 36
Make sure to visit us for: Tutorials Articles Projects And much more
@www.AdvancedQTP.com