Requirement Req 0002 Implementation of Requirement Req 0002

  • Slides: 57
Download presentation
Requirement Req 0002 Implementation of Requirement Req 0002 Dani Vainstein & Monika Arora Gautam

Requirement Req 0002 Implementation of Requirement Req 0002 Dani Vainstein & Monika Arora Gautam 1

TIP n n Fr Project staff have made an improvement to the presentations. Whenever

TIP n n 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 follow : 1 2 Dani Vainstein & Monika Arora Gautam Click 2

Topics covered n n n n n Extending functionality on existing modules. Process design

Topics covered n n n n n Extending functionality on existing modules. Process design of a test. Build a new function. Adding single object to local repository. Checking single and multiple properties on an object. Standard and bitmap checkpoints. Create an initialization action. Create a generic login procedure. Call to an existing reusable-actions. Build a new test. Dani Vainstein & Monika Arora Gautam 3

Before You Start… n Before starting the presentation, read about the following topics in

Before You Start… n Before starting the presentation, read about the following topics in QTP help. q q q q q Window/Dialog Object - Exist Property. Window/Dialog Object - Activate Method. Reporter Object. Environment Object. System. Util. Run Method. Exit Statement. Const/Dim Statement. Select Case Statement. Desktop. Capture. Bitmap Method. Check. Property Method. Dani Vainstein & Monika Arora Gautam 4

Before You Start… n Before starting the presentation, read about the following topics in

Before You Start… n Before starting the presentation, read about the following topics in QTP help. q If…End If Statement. vb. Null. String Constant. Object Check. Property Method. Win. Edit, Win. Button, Static Objects. Standard Checkpoint. Bitmap Checkpoint Properties. q Call to an Existing Action. q q q Dani Vainstein & Monika Arora Gautam 5

Req 0002 - Overview n n User performs following testing on the ‘Login’ dialog.

Req 0002 - Overview n n User performs following testing on the ‘Login’ dialog. Before the user starts to enter any data : q q q q Req 0002 a - Label “Agent Name” is visible. Req 0002 b - Textbox “Agent Name” should be empty, enabled and focused. Req 0002 c - Label “Password” is visible. Req 0002 d - Textbox “Password” is empty and enabled. Req 0002 e - Command Button “OK” is enabled. Req 0002 f - Command Button “Cancel” is enabled. Req 0002 g - Command Button “Help” is enabled. Req 0002 h - Logo is displayed. Dani Vainstein & Monika Arora Gautam 6

Req 0002 - Overview Details Label displayed Logo Textbox empty Enabled and focused Label

Req 0002 - Overview Details Label displayed Logo Textbox empty Enabled and focused Label displayed Textbox empty and enabled Command button Enabled. enabled Dani Vainstein & Monika Arora Gautam 7

Process Design – Req 0002 Start Invoke App Failed Dialog Login Exists? Yes Report

Process Design – Req 0002 Start Invoke App Failed Dialog Login Exists? Yes Report mic. Fail Passed Report mic. Pass Req 0002 a Invoke. App Function No Report mic. Failed Report mic. Fail Exit. Test Dani Vainstein & Monika Arora Gautam Passed Req 0002 h Report mic. Pass End 8

Process Design – Req 0002 n n First we need a regular invoke application

Process Design – Req 0002 n n First we need a regular invoke application process Then we need to verify that the “invoke application” process was done successful, before accessing the dialog. If the process failed, it means the login dialog wasn’t displayed and hence test is failed so there is no point to continue testing. Then the Req 0002 process starts from Req 0002 a to Req 0002 h Dani Vainstein & Monika Arora Gautam 9

Building a Generic Function - Application Invoke Process n n To implement the invoke

Building a Generic Function - Application Invoke Process n n To implement the invoke application process we are going to use a function ( Utils Layer ). Why a function for invoke application? We are assuming that this process is necessary for all the tests. Dani Vainstein & Monika Arora Gautam 10

Analyzing FR Application scenarios invoke Dialog “Login” Exists Window “Flight Reservation” Exist Activate Executable

Analyzing FR Application scenarios invoke Dialog “Login” Exists Window “Flight Reservation” Exist Activate Executable False True False True N/A Dani Vainstein & Monika Arora Gautam 11

Activation Conditions 1. 2. 3. 4. If “Flight Reservation” (main) main window is already

Activation Conditions 1. 2. 3. 4. If “Flight Reservation” (main) main window is already displayed, don’t activate the executable file. We want to avoid multiple application instances. If the “Login” dialog is already displayed, don’t activate. We want to avoid multiple application instances. If “Login” dialog is NOT displayed AND the “Flight. Reservation” window is NOT displayed activate Flight 4 x. exe. Main Flight Reservation window and login are opened. This scenario case can never happened. Dialog “Login” and “Flight Reservation” window can’t be opened at the same time. Dani Vainstein & Monika Arora Gautam 12

Application invoke considerations. n The main thing we want to avoid when running scripts

Application invoke considerations. n The main thing we want to avoid when running scripts on Flight Reservation, is multiple instances of Flight Reservation application. Therefore we need the Invoke. App Function. Avoid This!!! Dani Vainstein & Monika Arora Gautam 13

Application invoke considerations. n Invoke. App function covers the following functionality q q q

Application invoke considerations. n Invoke. App function covers the following functionality q q q The function should check that no other instance/s are already open. The function should contain generic process assuming that the application instance is probably open and working accordingly. The function should also check a successful activation of the executable. Dani Vainstein & Monika Arora Gautam 14

Invoke. App Design <version> Start Flight Reservation Exists? No Dialog Login Exists? No Yes

Invoke. App Design <version> Start Flight Reservation Exists? No Dialog Login Exists? No Yes Invoke App Dialog Login Exists? Report mic. Fail End End False True Dani Vainstein & Monika Arora Gautam False 15

Adding Functionality to existing module Automation FR n LIB RA BL n GL RS

Adding Functionality to existing module Automation FR n LIB RA BL n GL RS n Open the function library FR. vbs Menu : File Open Function Library Hotkeys : Shift + Alt + O DOC DAT SETTING TESTS RES BATCH Fr. vbs ENV Dani Vainstein & Monika Arora Gautam 16

Creating Invoke. App Function Name: Invoke. App exec. Version By value Type: Function Scope:

Creating Invoke. App Function Name: Invoke. App exec. Version By value Type: Function Scope: Public Description Documentation Dani Vainstein & Monika Arora Gautam 17

Invoke. App – Initialization '@Description Invokes application flight reservation version xx '@Documentation Invokes application

Invoke. App – Initialization '@Description Invokes application flight reservation version xx '@Documentation Invokes application flight reservation < exec. Version> Public Function Invoke. App( By. Val exec. Version ) Dim exec. Path, msg ' local variables ' initialization Invoke. App = False n Initialize the function to false, as a default return value of the function Dani Vainstein & Monika Arora Gautam 18

Invoke. App – Condition 1 ' ** condition 1 - Window displayed don't activate

Invoke. App – Condition 1 ' ** condition 1 - Window displayed don't activate executable If Window( "regexpwndtitle: =Flight Reservation" ). Exist( 0 ) Then Window( "regexpwndtitle: =Flight Reservation" ). Activate mic. Left. Btn msg = "Flight Reservation is already displayed. " Reporter. Report. Event mic. Done, "Invoke. App", msg Exit Function End If n n Since we are using a generic function we are using Descriptive Programming ( DP ). If the “Flight Reservation” window exists, the window will be activated and a general message will be sent to the Reporter. Dani Vainstein & Monika Arora Gautam 19

Invoke. App – Condition 2 ' ** condition 2 - Dialog Login is displayed

Invoke. App – Condition 2 ' ** condition 2 - Dialog Login is displayed don't activate executable If Dialog( "text: =Login", "nativeclass: =#32770" ). Exist( 0 ) Then Dialog( "text: =Login", "nativeclass: =#32770" ). Activate mic. Left. Btn msg = "Dialog Login is already displayed. " Reporter. Report. Event mic. Done, "Invoke. App", msg Exit Function End If n If the “Login” dialog exists, the dialog will be activated and a general message will sent to the Reporter. Dani Vainstein & Monika Arora Gautam 20

Invoke. App – Invoke executable ' ** invoking executable. . . exec. Path =

Invoke. App – Invoke executable ' ** invoking executable. . . exec. Path = Environment( "Product. Dir" ) & APP_PATH ' build path. . . System. Util. Run exec. Version, vb. Null. String, exec. Path, "open" n Before using System. Util. Run method, we need to build the path of the executable, as the Run method requires this argument. Dani Vainstein & Monika Arora Gautam 21

Invoke. App Function If Dialog( "text: =Login", "nativeclass: =#32770" ). Exist( 5 ) =

Invoke. App Function If Dialog( "text: =Login", "nativeclass: =#32770" ). Exist( 5 ) = False Then msg = "Dialog 'Login' is not displayed after 5 seconds. " Reporter. Report. Event mic. Fail, "Application. Exception", msg Exit Function End If Invoke. App = True ' Application was invoked n n n Immediately after invoking, we’ll check that “Login” exists, with a max wait of 5 seconds, just in case… If the dialog didn’t show up after 5 seconds, this can be a defect, we fail the test, and exit the function. If the dialog exists, the function will return True. Dani Vainstein & Monika Arora Gautam 22

Invoke. App – Final Look Dani Vainstein & Monika Arora Gautam n Add the

Invoke. App – Final Look Dani Vainstein & Monika Arora Gautam n Add the function Invoke. App to File library. n Save the function library n You should have 2 functions. 23

Creating new step n Open gui. Login test and add a new step Case

Creating new step n Open gui. Login test and add a new step Case “req 0002” ( remember to write the string in lower case ) Dani Vainstein & Monika Arora Gautam 24

Implementing Req 0002 a Dialog( "Login" ). Static( "Agent. Name" ). Check. Property "visible",

Implementing Req 0002 a Dialog( "Login" ). Static( "Agent. Name" ). Check. Property "visible", True, 1000 ' ** Req 0002 a n n Req 0002 a uses the Check. Property method of static, with argument “visible”, value True The method will auto-report to Reporter object. Dani Vainstein & Monika Arora Gautam 25

Implementing Req 0002 b n n Req 0002 b checks 3 properties on 1

Implementing Req 0002 b n n Req 0002 b checks 3 properties on 1 object viz. enabled, focused and text. It is recommended to use checkpoint for this purpose. However, many QTP developers prefer to use various Check. Property methods instead of a checkpoint, because of the complexity and portability issue of managing checkpoints. This problem will be solved on QTP 9. 5 Before starting to record, the Login dialog must be displayed. Make sure that only one instance of Flight Application is opened. Dani Vainstein & Monika Arora Gautam 26

Inserting a Standard Checkpoint n Start Recording : q q q Menu : Automation

Inserting a Standard Checkpoint n Start Recording : q q q Menu : Automation Record. Hotkey : F 3 From toolbar as shown below: Record Dani Vainstein & Monika Arora Gautam 27

Insert Standard Checkpoint n n n Menu : Insert Checkpoint Standard Checkpoint… Hotkey :

Insert Standard Checkpoint n n n Menu : Insert Checkpoint Standard Checkpoint… Hotkey : F 12 Toolbar as shown below: Dani Vainstein & Monika Arora Gautam 28

Insert Standard Checkpoint n With the finger-point select the “Agent Name” Win. Edit object.

Insert Standard Checkpoint n With the finger-point select the “Agent Name” Win. Edit object. Dani Vainstein & Monika Arora Gautam 29

Insert Standard Checkpoint Name : Req 0002 b enabled = True Except property enabled,

Insert Standard Checkpoint Name : Req 0002 b enabled = True Except property enabled, text and focused, focused = True All the other properties must be Unchecked!! text = Timeout = 2 Dani Vainstein & Monika Arora Gautam 30

Implement Req 0002 b Dialog( "Login" ). Win. Edit("Agent. Name"). Check. Point( "Req 0002

Implement Req 0002 b Dialog( "Login" ). Win. Edit("Agent. Name"). Check. Point( "Req 0002 b" ) ' ** Req 0002 n Anytime you can mark the word Checkpoint and see the checkpoint properties. Dani Vainstein & Monika Arora Gautam 31

Implementing Req 0002 c Dialog( "Login" ). Static( "Password" ). Check. Property "visible", True,

Implementing Req 0002 c Dialog( "Login" ). Static( "Password" ). Check. Property "visible", True, 1000 ' ** Req 0002 c n n Req 0002 c uses the Check. Property method of Static object, with argument “visible”, value True The method will auto-report to Reporter object. Dani Vainstein & Monika Arora Gautam 32

Implementing Req 0002 d Dialog("Login"). Win. Edit( "Password" ). Check. Property "enabled", True, 1000

Implementing Req 0002 d Dialog("Login"). Win. Edit( "Password" ). Check. Property "enabled", True, 1000 ' ** Req 0002 d Dialog("Login"). Win. Edit( "Password" ). Check. Property "text", vb. Null. String, 1000' ** Req 0002 d n n Req 0002 d uses the Check. Property method of Win. Edit, with argument “enabled” value True, and “text” with value vb. Null. String ( represents an empty string ) Instead of using checkpoint we can alternatively add 2 Check. Property methods. Dani Vainstein & Monika Arora Gautam 33

Req 0002 e, Req 0002 f, Req 0002 g Dialog( "Login" ). Win. Button(

Req 0002 e, Req 0002 f, Req 0002 g Dialog( "Login" ). Win. Button( "OK" ). Check. Property "enabled", True, 1000 ' ** Req 0002 e Dialog( "Login" ). Win. Button( "Cancel" ). Check. Property "enabled", True, 1000 ' ** Req 0002 f Dialog( "Login" ). Win. Button( "Help" ). Check. Property "enabled", True, 1000 ' ** Req 0002 g n n The requirement is only to check if they are enabled. don’t check any property that is not required. The method will auto-report to Reporter object. Dani Vainstein & Monika Arora Gautam 34

Implementing Req 002 h n After req 0002 h press ENTER to move to

Implementing Req 002 h n After req 0002 h press ENTER to move to next line. n In the end off the following line press enter Dialog("Login"). Win. Button("Help"). Check. Property "enabled", True, 1000 n n Make sure the cursor is on a new blank line, and then start recording. Before you start recording, make sure dialog Login is displayed. and only one instance of the application is opened. Dani Vainstein & Monika Arora Gautam 35

Inserting a bitmap checkpoint Select Bitmap Checkpoint… Dani Vainstein & Monika Arora Gautam 36

Inserting a bitmap checkpoint Select Bitmap Checkpoint… Dani Vainstein & Monika Arora Gautam 36

Inserting a bitmap checkpoint n n Select The Logo with the finger point. Select

Inserting a bitmap checkpoint n n Select The Logo with the finger point. Select the Static and Click OK Dani Vainstein & Monika Arora Gautam 37

Inserting a bitmap checkpoint n n n Change the name of the checkpoint to

Inserting a bitmap checkpoint n n n Change the name of the checkpoint to “Logo”. Change the checkpoint timeout to 2 seconds. Click OK. Dani Vainstein & Monika Arora Gautam 38

Inserting a bitmap checkpoint STOP recording ' ** Checking the logo using bitmap checkpoint

Inserting a bitmap checkpoint STOP recording ' ** Checking the logo using bitmap checkpoint req 0002 h Dialog( "Login" ). Static( "Logo" ). Check. Point( "Logo" ) n The checkpoint syntax will be inserted automatically at mentioned location. Dani Vainstein & Monika Arora Gautam 39

Req 0002 ( gui. Login ) – Final Look Dani Vainstein & Monika Arora

Req 0002 ( gui. Login ) – Final Look Dani Vainstein & Monika Arora Gautam 40

Implement Business Action for Req 0002 n n Open the bus. Login test. Select

Implement Business Action for Req 0002 n n Open the bus. Login test. Select the bus. Login. Mng action. Insert a new test-case after case “req 0001”. Use lower-case ( Case “<lower-case>” ) Select Case LCase( Parameter. Item( "bus. Code" ) ) Case "req 0001" : Case "req 0002" Case Else msg = "Action. Code parameter not implemented. " Reporter. Report. Event mic. Warning, "Not. Implemeted. Exception", msg Exit. Action( mic. Warning ) End Select Dani Vainstein & Monika Arora Gautam 41

Business Req 0002 implementation n n According our design [ Process Design – Req

Business Req 0002 implementation n n According our design [ Process Design – Req 0002 ] we need to invoke the application and then call the GUI process Req 0002, We’ll call Invoke. App function from the test layer What’s left now, is to call the “Req 0002” GUI process located in gui. Login. Dani Vainstein & Monika Arora Gautam 42

bus. Login. Mng – Final Look n n As mentioned in previous presentation do

bus. Login. Mng – Final Look n n As mentioned in previous presentation do not just copy this line of code, a call to an existing reusable action is required. add the input parameter “Req 0002”, while calling the existing action gui. Login. Dani Vainstein & Monika Arora Gautam 43

Create Req 0002 Test Automation FR n LIB RA BL Open a new blank

Create Req 0002 Test Automation FR n LIB RA BL Open a new blank test and save it under TESTSReq 0002 GL RS DOC DAT SETTING Req 0002 TESTS RES BATCH ENV Dani Vainstein & Monika Arora Gautam 44

Test Settings n Modify the test settings… Dani Vainstein & Monika Arora Gautam 45

Test Settings n Modify the test settings… Dani Vainstein & Monika Arora Gautam 45

Associated function libraries n Dani Vainstein & Monika Arora Gautam If you don’t see

Associated function libraries n Dani Vainstein & Monika Arora Gautam If you don’t see the LIBFR. vbs file associated you must to permanently associate the function library; For instructions how to permanently associate function libraries, see previous presentation. 46

Test Header '************************************ '@Author : advanced. QTP '@Date Created : <ddd MMM dd, yyyy>

Test Header '************************************ '@Author : advanced. QTP '@Date Created : <ddd MMM dd, yyyy> '@QTP Version : 9. 2 '@Description : The test covers the requirement Req 0002 '@Input Parameter : None. '@Out Parameter : None. '@Ass. Libraries : FR. vbs '@Addins : Active. X '@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 47

Implementing Test Req 0002 Option Explicit Dim msg Call Initialization() If Reporter. Run. Status

Implementing Test Req 0002 Option Explicit Dim msg Call Initialization() If Reporter. Run. Status = mic. Fail Then msg = "Initialization Process Failed. " Reporter. Report. Event mic. Fail, Environment( "Test. Name" ), msg Exit. Test( mic. Fail ) End If n The Initialization part is exactly the same for all tests. Dani Vainstein & Monika Arora Gautam 48

Implementing Test Req 0002 ' ** invoking application Call Invoke. App( Environment. Value( "EXE_FILE"

Implementing Test Req 0002 ' ** invoking application Call Invoke. App( Environment. Value( "EXE_FILE" ) ) If Reporter. Run. Status = mic. Fail Then msg = "Invoke Application Failed. " Reporter. Report. Event mic. Fail, Environment( "Test. Name" ), msg Exit. Test( mic. Fail ) End If n A call to function Invoke. App is required to activate the executable file. Dani Vainstein & Monika Arora Gautam 49

Insert a Call to Existing Action Dani Vainstein & Monika Arora Gautam 50

Insert a Call to Existing Action Dani Vainstein & Monika Arora Gautam 50

Insert a Call to Business Module Dani Vainstein & Monika Arora Gautam 51

Insert a Call to Business Module Dani Vainstein & Monika Arora Gautam 51

Insert a Call to Existing Action Use relative path bus. Login. Mng After the

Insert a Call to Existing Action Use relative path bus. Login. Mng After the current step Dani Vainstein & Monika Arora Gautam 52

Req 0002 Test – Final Look Do not forget to check syntax before closing

Req 0002 Test – Final Look Do not forget to check syntax before closing action Dani Vainstein & Monika Arora Gautam 53

Result Req 0002 Dani Vainstein & Monika Arora Gautam 54

Result Req 0002 Dani Vainstein & Monika Arora Gautam 54

What’s Next? n n n Implement Login. Regression Test. Req 0003. Calling an existing

What’s Next? n n n Implement Login. Regression Test. Req 0003. Calling an existing library function. Creating an external data source. Loading an external data source. Create a dynamic standard checkpoint. Dani Vainstein & Monika Arora Gautam 55

Special Thanks To n n Tali Hizkia from Israel, Tel-Aviv. Bharathi Babu from India,

Special Thanks To n n Tali Hizkia from Israel, Tel-Aviv. Bharathi Babu from India, Pune. Dalvinder Matharu from USA, San Jose. Mike Manchester from USA, Bolivar Dani Vainstein & Monika Arora Gautam 56

Make sure to visit us for: n n Tutorials Articles Projects And much more

Make sure to visit us for: n n Tutorials Articles Projects And much more @ www. advancedqtp. com Dani Vainstein & Monika Arora Gautam 57