Flight reservation module
Download
1 / 71

Flight Reservation Module - PowerPoint PPT Presentation


  • 95 Views
  • Uploaded on

Flight Reservation Module. Implementation of Flight Reservation. Topics covered. Exporting Data-tables. Checkpoints and CheckProperty method. Testing ActiveX test objects. Mapping objects using filter. Implementation of Req0010 to Req0015. Before you start….

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Flight Reservation Module' - cedric


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Flight reservation module

Flight Reservation Module

Implementation of Flight Reservation

Dani Vainstein & Monika Arora Gautam


Topics covered
Topics covered

  • Exporting Data-tables.

  • Checkpoints and CheckProperty method.

  • Testing ActiveX test objects.

  • Mapping objects using filter.

  • Implementation of

    • Req0010 to Req0015

Dani Vainstein & Monika Arora Gautam


Before you start
Before you start…

  • Before starting the presentation, read about the following topics in QTP help.

    • WinObject object.

    • ActiveX object.

    • Run-time properties.

    • WinMenu.CheckItemProperty method.

    • ExitActionIteration statement.

    • WinMenu.ExpandMenu property.

    • WinMenu.BuildPath method.

    • DataTable object.

Dani Vainstein & Monika Arora Gautam


Guifr module
guiFR Module

Open a new blank test and save it as “guiFR” under the folder FR\RA\GL

Automation

FR

LIB

RA

BL

GL

RS

DOC

DAT

SETTING

TESTS

RES

BATCH

ENV

guiFR

4

Dani Vainstein & Monika Arora Gautam


Guifr introduction
guiFR - Introduction

  • We are going to create a new test, classified as a GUI module, and a reusable action.

  • The module name would be guiFR, because it will handles the “Flight Reservation” window.

  • This action will be called GuiFR because the reusable action is going to handle all the operations on FR windows .

  • The guiFR will receive a single input parameter (StepName) of String type.

  • As you might have noticed in previous presentations all guiXX actions have one and only one input parameter.

Dani Vainstein & Monika Arora Gautam


Guifr settings
guiFR Settings

From Menu  Edit  Action  Action Properties

6

Dani Vainstein & Monika Arora Gautam


Guifr general tab
guiFR - General Tab

Change

Action

Name

Add

Description

Mark

Reusable

7

Dani Vainstein & Monika Arora Gautam


Parameters tab add stepname
Parameters Tab – Add StepName

Add a new Input Parameter ( Click on + )

Add

StepName

Input

Parameter

Add

Description

Type

String

Default

Leave Empty

Click OK

8

Dani Vainstein & Monika Arora Gautam


Adding objects to local repository
Adding Objects to Local Repository

Open the Flight Application from Start  All Programs  QuickTest Professional  Sample Applications  Flight.

Login to FR.

9

Dani Vainstein & Monika Arora Gautam


Adding objects to local repository1
Adding Objects to Local Repository

Open the local object repository from Menu  Resources  Object Repository.

Or just press < Ctrl + R > in QTP application.

Click Add objects in toolbar or select Object > Add objects to local repository from menu-bar.

QTP will show an hand icon.

Click Add objects in toolbar

Or

Object  Add objects To Local…

10

Dani Vainstein & Monika Arora Gautam


Mapping objects

Verify WinObject is unchecked under Miscellaneous

Mapping objects

Select The

Window Title

With the point hand

Dani Vainstein & Monika Arora Gautam


Mapping objects1
Mapping Objects

Dani Vainstein & Monika Arora Gautam


Naming conventions
Naming conventions

All the objects will be added to the local repository.

While mapping the FR window we can see how naming conventions can be effective.

Which button is Button_2? and Button_4?

Which object is MaskEdBox?

Rename all objects; use the “Highlight in Application” and “Locate in Repository” features.

When an object was located, right-click on the object logical name ( left pane ) and select “Rename”.

13

Dani Vainstein & Monika Arora Gautam


Naming conventions1
Naming conventions

Extended View

Compact View

14

Dani Vainstein & Monika Arora Gautam


Guifr header
guiFR Header

'***********************************************************************

[email protected] : advancedQTP

[email protected] Created : <ddd MMM dd, yyyy>

[email protected] Version : 9.2

[email protected] : The guiFR Module Stores all the actions required for the Main screen.

[email protected] Parameter : Name:=StepName, Type:=String, Default:=, Description:=The Step code name.

[email protected] Parameter : None.

[email protected] Window : Window "Flight Reservation"

[email protected] : ActiveX

[email protected] : <#n By <Name>, Date: <dd-mmm-yyyy>> (Later modification on top)

' <#n-1 By <Name>, Date: <dd-mmm-yyyy>

'***********************************************************************

Option Explicit

Dani Vainstein & Monika Arora Gautam


Guifr template
guiFR Template

Option Explicit

Dim msg

SelectCaseLCase( Parameter.Item( "StepName" ) )

Case ...

Case ...

CaseElse

Reporter.ReportEvent micWarning, "NotImplementedException", Parameter( "StepName" )

ExitAction( micWarning )

EndSelect

Dani Vainstein & Monika Arora Gautam


Implementing req0010
Implementing Req0010

  • There are 6 bitmap checkpoints and 6 property checks.

  • It is not possible to merge a bitmap checkpoint to a Standard checkpoint, so we are going to use the CheckProperty method of the WinButton object.

Dani Vainstein & Monika Arora Gautam


Implementing req00101
Implementing Req0010

  • Add a new “Case” to the Select Case statement.

  • Remember to use lower-case since the Select Case condition is converted to lower case ( LCase Function )

Dani Vainstein & Monika Arora Gautam


Req0010 bitmap checkpoints

Avoid This!!!

Req0010 – Bitmap Checkpoints

  • To insert a bitmap checkpoint we must be in “Record” mode.

  • Before pressing RECORD, place the cursor below the Case “req0010” be sure only one instance of “Flight Reservation” application is opened.

  • Put the cursor on line 19 ( just below case “req0010” )

Dani Vainstein & Monika Arora Gautam


Inserting a bitmap checkpoint

Name: Req0010a

Timeout : 2

Inserting a Bitmap Checkpoint

  • Be sure you are in Recording Mode ( Status Bar Message blinking )

  • Select from menu : Insert  Checkpoint  Bitmap checkpoint.

  • With the pointing hand, select the “New Order” button.

  • Then without stopping continue to the rest of buttons one after another.

Dani Vainstein & Monika Arora Gautam


Req0010 implementation
Req0010 - Implementation

  • Place the cursor below the last checkpoint and press F7.

  • You will see the step generator.

    • Category : Test Objects.

    • Click the object icon on right.

Dani Vainstein & Monika Arora Gautam


Req0010a using the step generator
Req0010a – Using the Step Generator

Type: Button

Name: New

Dani Vainstein & Monika Arora Gautam


Req0010a using the step generator1
Req0010a – Using the Step Generator

Operation:

CheckProperty

PropertyName:

enabled

Documentation:

Click For Documentation

PropertyValue

True

Timeout

2000

Dani Vainstein & Monika Arora Gautam


Step generator
Step Generator…

  • For some reason the Step Generator, converts “Any” values to string. So we need to fix the strings “True” to Boolean True.

  • Repeat above steps for rest of the bitmap checkpoints.

Fix Manually

Dani Vainstein & Monika Arora Gautam


Checkpoints
Checkpoints

  • Place the cursor below the checkpoint created for “req0010b” and press F7.

  • Repeat Steps discussed from slide # 21 to 24.

  • Repeat above steps for rest of the bitmap checkpoints.

  • Do not forget to change string “True” to boolean TRUE and for Delete “PropertyValue” should be FALSE.

Dani Vainstein & Monika Arora Gautam


Req0010 case modifying
Req0010 Case - Modifying

Modify Script for better look and fit to code standards

Dani Vainstein & Monika Arora Gautam


Req0010 case keyword view
Req0010 Case – Keyword View

Dani Vainstein & Monika Arora Gautam


Implementing req0011
Implementing Req0011

  • Req0011 checks also the properties of the “Date of Flight” field.

  • The “Date of Flight” field is an ActiveX object we have to test 5 properties.

  • “Flight From” and “Flight To” has two properties to be tested. To test these 2 properties we will use standard checkpoints.

Dani Vainstein & Monika Arora Gautam


Implementing req00111
Implementing Req0011

  • Press on record, and insert a standard checkpoint for this object.

Dani Vainstein & Monika Arora Gautam


Implementing req0011a
Implementing Req0011a

  • Rename the checkpoint to “Req0011a” and only check the required properties

Dani Vainstein & Monika Arora Gautam


Modifying checkpoints
Modifying Checkpoints

  • If you find that you made a mistake on selecting properties you can always edit you checkpoints.

  • Select the word “Checkpoint” and right-click.

  • In the popup menu select “Checkpoint Properties…”

Dani Vainstein & Monika Arora Gautam


Implementing req0011b and req0011c
Implementing Req0011b and Req0011c.

  • Add a standard checkpoint for “Fly From” and “Fly To”.

  • Give the name “Req0011b” and “Req0011c” respectively.

Dani Vainstein & Monika Arora Gautam


Implementing req0011d
Implementing Req0011d

  • Since Req0011d checks only one property, we will insert the checkProperty method manually or via “Step Generator” .

  • Use QTP intellisense when typing.

Dani Vainstein & Monika Arora Gautam


Implementing req0012
Implementing Req0012

Dani Vainstein & Monika Arora Gautam


Implementing req00121
Implementing Req0012

  • All the fields from “a” to “i” except “e” are disabled all the time, they are just information fields.

  • The thing that we need to test here is not that fields should be enabled but that fields are not displaying any data, all fields should be empty.

Dani Vainstein & Monika Arora Gautam


Implementing req0013
Implementing Req0013

Dani Vainstein & Monika Arora Gautam


Implementing req00131
Implementing Req0013

Dani Vainstein & Monika Arora Gautam


Implementing req0013 menu defaults
Implementing Req0013 – Menu Defaults

  • We are checking the WinMenu object.

  • To check a menu item, we are going to use the CheckItemProperty method because it is not supported by any standard checkpoint.

  • Menu item exists.

    • Window( “FR” ).WinMenu( “Menu” ).CheckItemProperty “<item>”, “Exists”, True, 2000

  • Menu item enabled.

    • Window( “FR” ).WinMenu( “Menu” ).CheckItemProperty “<item>”, “Enabled”, True, 2000

  • Menu item index.

    • Window( “FR” ).WinMenu( “Menu” ).CheckItemProperty “<item>”, “Index”, <n>, 2000

  • Menu item label.

    • Window( “FR” ).WinMenu( “Menu” ).CheckItemProperty “<item>”, “Label”, <label>, 2000

  • Menu item SubMenuCount.

    • Window( “FR” ).WinMenu( “Menu” ).CheckItemProperty “<item>”, “SubMenuCount”, < count >, 2000

Dani Vainstein & Monika Arora Gautam


Implementing req0013 menu defaults1
Implementing Req0013 – Menu Defaults

  • We need to “check” 15 menu items and 7 properties each ( 105 lines of code ).

  • We can repeat the code ‘7’ times, for each menu item; that will work, but, it will require a lot of coding, and if, in the future, something changes in Menu, then it will require more time in maintenance.

  • For this specific requirement I have chosen a “smart” method.

  • I will create an excel sheet with the expected results and use the QTP iteration mechanism, so now, the only thing left is to maintain an excel-sheet, and not the code.

  • Earlier we learned how to import an excel sheet, now we’ll see how to export an excel sheet.

  • Select the Local Sheet “guiFR”

Dani Vainstein & Monika Arora Gautam


Req0013 process design
Req0013 Process Design

< CHECK >

Index :

Start

<n> Rows

Loop

<rows>

Index?

Y

Index

Failed

Exists?

Y

Exists

HasSubMenu?

Y

HasSubMenu

Enabled?

Y

Enabled

SubMenuCount?

Label?

Y

Y

SubMenuCount

Label

Dani Vainstein & Monika Arora Gautam


Req0013 process design1
Req0013 Process Design

< CHECK >

Index :

Start

<n> Rows

Loop

<rows>

Index?

Y

Index

Failed

Exists?

Y

Exists

HasSubMenu?

Y

HasSubMenu

Enabled?

Y

Enabled

SubMenuCount?

Label?

Y

Y

SubMenuCount

Label

Dani Vainstein & Monika Arora Gautam


Exporting a data sheet
Exporting a Data-Sheet

  • If you don’t see the Data Table select from menu View  Data Table

  • Or from the toolbar as shown below.

View Data Table

Dani Vainstein & Monika Arora Gautam


Inserting a new data column
Inserting a new Data-Column

  • You can insert/change the name of a column for a parameter by double-clicking the column heading cell.

Dani Vainstein & Monika Arora Gautam


Inserting a new data column1
Inserting a new Data-Column

  • Add the follow columns : “itemPath”, “menuItem”, “Exists”, “Enabled”, “HasSubMenu”, “Index”, “Label”, “SubMenuCount”

Dani Vainstein & Monika Arora Gautam


Exporting data table
Exporting Data Table

Dani Vainstein & Monika Arora Gautam


Modifying datasheet
Modifying Datasheet

  • Open FR\DAT\FR.xls

  • Delete line no. 2 ( remove the cell frames )

  • Rename sheet to “MenuDefaults”

  • You can optionally remove “Sheet2” and “Sheet3”

Dani Vainstein & Monika Arora Gautam


Entering data
Entering Data

Dani Vainstein & Monika Arora Gautam


Excel options
Excel Options

  • When I first wrote the excel file and run it, I found something very strange. My checkpoint failed with the following message :

  • If you have a sharp eye you can notice a minor difference..

  • If you still didn’t notice the difference, I'll tell you; the expected 3 dots, are wider than the actual 3 dots...mmmm

Dani Vainstein & Monika Arora Gautam


Excel options1
Excel Options

  • I researched, and almost got crazy, but then I found a solution.

  • The last 3 dots are NOT 3 characters, “those” are actually a single “symbol” character.

  • And why is it a 'single symbol' character? Because that is the way microsoft has designed it.

Dani Vainstein & Monika Arora Gautam


Excel options2
Excel Options

  • If you just type the string “Open Order...” in MS-Excel and press ENTER, you will see the following difference:

And not

  • The difference can be seen in better in “Courier New” font.

  • That’s the main reason that I recommend to use the “Courier” or “Courier New” fonts.

  • The AutoCorrect feature is defined by default to change the 3 dots.

  • Select in Excel menu : Tools > AutoCorrect Options... > AutoCorrect Tab

  • Uncheck the option “Replace text as you type”.

Dani Vainstein & Monika Arora Gautam


Implementing req00132
Implementing Req0013

  • Add a new Case “req0013”.

  • Remember to use lower-case.

Dani Vainstein & Monika Arora Gautam


Implementing req00133
Implementing Req0013

  • Notice that we have left some cells empty in the excel sheet.

  • According to SRS document the properties that we don't need to check are left empty.

  • The idea is to “check” data, only if the content of the cell is not empty.

If DataTable( "< column name >", dtLocalSheet ) <> "" Then

' ** CheckItemProperty...

EndIf

Dani Vainstein & Monika Arora Gautam


Implementing req00134
Implementing Req0013

  • Declare the variables that we’re going to use.

  • Reporting the current checked menu item.

  • Activate the FR Window.

Case"req0013"

Dim itemPath, bExists

Reporter.ReportEvent micDone, "Menu Item", DataTable( "menuItem", dtLocalSheet )

Window( "FR" ).Activate micLeftBtn

  • QTP Help : "Note: For better performance when running your test, you may want to set the ExpandMenu property to False"

Window( "FR" ).WinMenu( "Menu" ).ExpandMenu = False

Dani Vainstein & Monika Arora Gautam


Implementing req00135
Implementing Req0013

  • Retrieving the item path.

itemPath = Window("FR").WinMenu("Menu").BuildMenuPath( DataTable("itemPath",dtLocalSheet))

  • First, we want to verify if we need to check the property “Exists”, by checking if column “Exists” is not empty.

  • Instead of vbNullString you can use " ". I think that vbNullString is more “elegant”.

If DataTable( "Exists", dtLocalSheet ) <> vbNullStringThen

End If

Dani Vainstein & Monika Arora Gautam


Implementing req0013 checkitemproperty

Select Menu

Implementing Req0013 - CheckItemProperty

  • Put the cursor after the If statement and press F7 to open the Step Generator.

Test Objects

Dani Vainstein & Monika Arora Gautam


Implementing req0013 checkitemproperty1

CheckItemProperty

1. Parameter = Constant

2. itemPath

Implementing Req0013 - CheckItemProperty

Dani Vainstein & Monika Arora Gautam


Implementing req0013 checkitemproperty2
Implementing Req0013 - CheckItemProperty

CheckItemProperty

1. Parameter = Constant

2. Constant = Exists

Dani Vainstein & Monika Arora Gautam


Implementing req0013 checkitemproperty3
Implementing Req0013 - CheckItemProperty

CheckItemProperty

1. Parameter = DataTable

2. Current action sheet

3. Name = Exists

Dani Vainstein & Monika Arora Gautam


Implementing req0013 checkitemproperty4
Implementing Req0013 - CheckItemProperty

2. Return value = bExists

1. Timeout = 2000

Dani Vainstein & Monika Arora Gautam


Modifying
Modifying...

  • "itemPath" is a variable not a string. Manually modify the value.

  • Similarly change string “itemPath” to variable itemPath for the rest of the properties or insert the statements manually using QTP intellisense.

Dani Vainstein & Monika Arora Gautam


Applying with end with statement
Applying With…End With Statement

  • It is possible to apply “With....End With” statements automatically to the scripts.

  • However it is not recommended, because QTP’s intellisense feature does not work then.

  • This is a bug in QTP. However you can try to apply “With....End With” by selecting from menu Edit  Advanced  Apply with "With" to script, or just press < Ctrl + W >. see what happens!

  • You can restore to previous state by typing < Ctrl + Shift + W >

  • If you have to apply “With....End With” to a specific area, you will have to do it manually.

  • If intellisense would also works with “With....End With” statement, it will be a great advantage, as the statements make code more readable.

Dani Vainstein & Monika Arora Gautam


Requirement req0013 final look
Requirement Req0013 – Final Look

Dani Vainstein & Monika Arora Gautam


Requirement req0014 and req0015
Requirement Req0014 and Req0015

Dani Vainstein & Monika Arora Gautam


Implementing req0014
Implementing Req0014

  • In the Summary Frame we need to check 2 objects. Those are 2 CheckProperty methods.

  • Use QTP intellisense to complete the commands.

Dani Vainstein & Monika Arora Gautam


Implementing req0015
Implementing Req0015

  • Req0015 is just a bitmap checkpoint to the image.

  • Since the image is not in the repository we need to add it.

  • To open the local repository type Ctrl + R.

Dani Vainstein & Monika Arora Gautam


Inserting a single object to local repository
Inserting a single object to Local Repository

Add objects to Local

Select with the finger point the image.

Dani Vainstein & Monika Arora Gautam


Inserting a single object to local repository1
Inserting a single object to Local Repository

  • Change "Static" to "Image"

Dani Vainstein & Monika Arora Gautam


Implementing req00151
Implementing Req0015

  • Insert a bitmap checkpoint. Start recording, and remember, only one instance of the Flight Reservation application should be opened.

  • Stop recording after inserting the bitmap checkpoint.

Dani Vainstein & Monika Arora Gautam


Req0015 final look
Req0015 – Final Look

  • A good practice is to Activate the window before a bitmap checkpoint.

Dani Vainstein & Monika Arora Gautam


What s next
What’s Next?

  • We have already seen how to implement a single test for each requirement.

  • In next presentation we are going to learn a different method; To test a group of requirements ( GUI Defaults ) in a single test.

  • We call it the Keyword-Data Driven method.

Dani Vainstein & Monika Arora Gautam


Make sure to visit us for
Make sure to visit us for:

Tutorials

Articles

Projects

And much more

@

www.AdvancedQTP.com

71

Dani Vainstein & Monika Arora Gautam


ad