Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dani Vainstein & Monika Arora Gautam 1 Requirement Req0002 Implementation of Requirement Req0002.

Similar presentations


Presentation on theme: "Dani Vainstein & Monika Arora Gautam 1 Requirement Req0002 Implementation of Requirement Req0002."— Presentation transcript:

1 Dani Vainstein & Monika Arora Gautam 1 Requirement Req0002 Implementation of Requirement Req0002

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

3 Dani Vainstein & Monika Arora Gautam 3 Topics covered 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.

4 Dani Vainstein & Monika Arora Gautam 4 Before You Start… Before starting the presentation, read about the following topics in QTP help.  Window/Dialog Object - Exist Property.  Window/Dialog Object - Activate Method.  Reporter Object.  Environment Object.  SystemUtil.Run Method.  Exit Statement.  Const/Dim Statement.  Select Case Statement.  Desktop.CaptureBitmap Method.  CheckProperty Method.

5 Dani Vainstein & Monika Arora Gautam 5 Before You Start… Before starting the presentation, read about the following topics in QTP help.  If…End If Statement.  vbNullString Constant.  Object CheckProperty Method.  WinEdit, WinButton, Static Objects.  Standard Checkpoint.  Bitmap Checkpoint.  Checkpoint Properties.  Call to an Existing Action.

6 Dani Vainstein & Monika Arora Gautam 6 Req0002 - Overview User performs following testing on the ‘Login’ dialog. Before the user starts to enter any data :  Req0002a - Label “Agent Name” is visible.  Req0002b - Textbox “Agent Name” should be empty, enabled and focused.  Req0002c - Label “Password” is visible.  Req0002d - Textbox “Password” is empty and enabled.  Req0002e - Command Button “OK” is enabled.  Req0002f - Command Button “Cancel” is enabled.  Req0002g - Command Button “Help” is enabled.  Req0002h - Logo is displayed.

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

8 Dani Vainstein & Monika Arora Gautam 8 Process Design – Req0002 End Req0002a Passed Failed Report micFail Report micPass Req0002h Passed Failed Report micFail Report micPass No Dialog Login Exists? ExitTest Yes Report micFail Invoke App Start

9 Dani Vainstein & Monika Arora Gautam 9 Process Design – Req0002 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 Req0002 process starts from Req0002a to Req0002h

10 Dani Vainstein & Monika Arora Gautam 10 Building a Generic Function - Application Invoke Process 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.

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

12 Dani Vainstein & Monika Arora Gautam 12 Activation Conditions 1. If “Flight Reservation” (main) main window is already displayed, don’t activate the executable file. We want to avoid multiple application instances. 2. If the “Login” dialog is already displayed, don’t activate. We want to avoid multiple application instances. 3. If “Login” dialog is NOT displayed AND the “FlightReservation” window is NOT displayed  activate Flight4x.exe. 4. 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.

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

14 Dani Vainstein & Monika Arora Gautam 14 Application invoke considerations. InvokeApp function covers the following functionality  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.

15 Dani Vainstein & Monika Arora Gautam 15 InvokeApp Design No Dialog Login Exists? Yes Report micFail End Start Flight Reservation Exists? Invoke App False No Dialog Login Exists? End False End True Yes

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

17 Dani Vainstein & Monika Arora Gautam 17 Creating InvokeApp Function Function Name: InvokeApp Type: Function Scope: Public execVersion By value Description Documentation

18 Dani Vainstein & Monika Arora Gautam 18 InvokeApp – Initialization '@Description Invokes application flight reservation version xx '@Documentation Invokes application flight reservation Public Function InvokeApp( ByVal execVersion ) Dim execPath, msg ' local variables ' initialization InvokeApp = False Initialize the function to false, as a default return value of the function

19 Dani Vainstein & Monika Arora Gautam 19 InvokeApp – Condition 1 ' ** condition 1 - Window displayed don't activate executable If Window( "regexpwndtitle:=Flight Reservation" ).Exist( 0 ) Then Window( "regexpwndtitle:=Flight Reservation" ).Activate micLeftBtn msg = "Flight Reservation is already displayed." Reporter.ReportEvent micDone, "InvokeApp", msg Exit Function End If 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.

20 Dani Vainstein & Monika Arora Gautam 20 InvokeApp – 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 micLeftBtn msg = "Dialog Login is already displayed." Reporter.ReportEvent micDone, "InvokeApp", msg Exit Function End If If the “Login” dialog exists, the dialog will be activated and a general message will sent to the Reporter.

21 Dani Vainstein & Monika Arora Gautam 21 InvokeApp – Invoke executable ' ** invoking executable... execPath = Environment( "ProductDir" ) & APP_PATH ' build path... SystemUtil.Run execVersion, vbNullString, execPath, "open" Before using SystemUtil.Run method, we need to build the path of the executable, as the Run method requires this argument.

22 Dani Vainstein & Monika Arora Gautam 22 InvokeApp Function If Dialog( "text:=Login","nativeclass:=#32770" ).Exist( 5 ) = False Then msg = "Dialog 'Login' is not displayed after 5 seconds." Reporter.ReportEvent micFail, "ApplicationException", msg Exit Function End If InvokeApp = True ' Application was invoked 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.

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

24 Dani Vainstein & Monika Arora Gautam 24 Creating new step Open guiLogin test and add a new step Case “req0002” ( remember to write the string in lower case )

25 Dani Vainstein & Monika Arora Gautam 25 Implementing Req0002a Req0002a uses the CheckProperty method of static, with argument “visible”, value True The method will auto-report to Reporter object. Dialog( "Login" ).Static( "AgentName" ).CheckProperty "visible", True, 1000 ' ** Req0002a

26 Dani Vainstein & Monika Arora Gautam 26 Implementing Req0002b Req0002b 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 CheckProperty 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.

27 Dani Vainstein & Monika Arora Gautam 27 Inserting a Standard Checkpoint Start Recording :  Menu : Automation  Record.  Hotkey : F3  From toolbar as shown below: Record

28 Dani Vainstein & Monika Arora Gautam 28 Insert Standard Checkpoint Menu : Insert  Checkpoint  Standard Checkpoint… Hotkey : F12 Toolbar as shown below:

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

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

31 Dani Vainstein & Monika Arora Gautam 31 Implement Req0002b Anytime you can mark the word Checkpoint and see the checkpoint properties. Dialog( "Login" ).WinEdit("AgentName").Check CheckPoint( "Req0002b" ) ' ** Req0002

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

33 Dani Vainstein & Monika Arora Gautam 33 Implementing Req0002d Req0002d uses the CheckProperty method of WinEdit, with argument “enabled” value True, and “text” with value vbNullString ( represents an empty string ) Instead of using checkpoint we can alternatively add 2 CheckProperty methods. Dialog("Login").WinEdit( "Password" ).CheckProperty "enabled", True, 1000 ' ** Req0002d Dialog("Login").WinEdit( "Password" ).CheckProperty "text", vbNullString, 1000' ** Req0002d

34 Dani Vainstein & Monika Arora Gautam 34 Req0002e, Req0002f, Req0002g Dialog( "Login" ).WinButton( "OK" ).CheckProperty "enabled", True, 1000 ' ** Req0002e Dialog( "Login" ).WinButton( "Cancel" ).CheckProperty "enabled", True, 1000 ' ** Req0002f Dialog( "Login" ).WinButton( "Help" ).CheckProperty "enabled", True, 1000 ' ** Req0002g 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.

35 Dani Vainstein & Monika Arora Gautam 35 Implementing Req002h After req0002h press ENTER to move to next line. In the end off the following line press enter Dialog("Login").WinButton("Help").CheckProperty "enabled", True, 1000 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.

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

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

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

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

40 Dani Vainstein & Monika Arora Gautam 40 Req0002 ( guiLogin ) – Final Look

41 Dani Vainstein & Monika Arora Gautam 41 Implement Business Action for Req0002 Open the busLogin test. Select the busLoginMng action. Insert a new test-case after case “req0001”. Use lower-case ( Case “ ” ) Select Case LCase( Parameter.Item( "busCode" ) ) Case "req0001" : Case "req0002" Case Else msg = "ActionCode parameter not implemented." Reporter.ReportEvent micWarning, "NotImplemetedException", msg ExitAction( micWarning ) End Select

42 Dani Vainstein & Monika Arora Gautam 42 Business Req0002 implementation According our design [ Process Design – Req0002 ] we need to invoke the application and then call the GUI process Req0002, We’ll call InvokeApp function from the test layerProcess Design – Req0002 What’s left now, is to call the “Req0002” GUI process located in guiLogin.

43 Dani Vainstein & Monika Arora Gautam 43 busLoginMng – Final Look 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 “Req0002”,while calling the existing action guiLogin.

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

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

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

47 Dani Vainstein & Monika Arora Gautam 47 Test Header '*********************************************************************** '@Author : advancedQTP '@Date Created : '@QTP Version : 9.2 '@Description : The test covers the requirement Req0002 '@Input Parameter : None. '@Out Parameter : None. '@Ass. Libraries : FR.vbs '@Addins : ActiveX '@Modifications :, Date: > (Later modification on top) ', Date: '***********************************************************************

48 Dani Vainstein & Monika Arora Gautam 48 Implementing Test Req0002 The Initialization part is exactly the same for all tests. Option Explicit Dim msg Call Initialization() If Reporter.RunStatus = micFail Then msg = "Initialization Process Failed." Reporter.ReportEvent micFail, Environment( "TestName" ), msg ExitTest( micFail ) End If

49 Dani Vainstein & Monika Arora Gautam 49 Implementing Test Req0002 A call to function InvokeApp is required to activate the executable file. ' ** invoking application Call InvokeApp( Environment.Value( "EXE_FILE" ) ) If Reporter.RunStatus = micFail Then msg = "Invoke Application Failed." Reporter.ReportEvent micFail, Environment( "TestName" ), msg ExitTest( micFail ) End If

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

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

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

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

54 Dani Vainstein & Monika Arora Gautam 54 Result Req0002

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

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

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


Download ppt "Dani Vainstein & Monika Arora Gautam 1 Requirement Req0002 Implementation of Requirement Req0002."

Similar presentations


Ads by Google