fr project

41
Dani Vainstein and Monika Aror Dani Vainstein and Monika Aror a Gautam a Gautam 1 FR Project Building and Setting-up the Infrastructure

Upload: zuwena

Post on 11-Jan-2016

36 views

Category:

Documents


0 download

DESCRIPTION

FR Project. Building and Setting-up the Infrastructure. Introduction. The FR project ( Flight Reservation ) is designated for all “First Step” users, who want to learn how to use QTP like in the “real” world of automation testing. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: FR Project

Dani Vainstein and Monika Arora GDani Vainstein and Monika Arora Gautamautam

1

FR Project

Building and Setting-up the Infrastructure

Page 2: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 2

Introduction

The FR project ( Flight Reservation ) is designated for all “First Step” users, who want to learn how to use QTP like in the “real” world of automation testing.

The FR step-by-step project will teach you: project design, use of advanced coding techniques, how to reduce script maintenance, use of modern testing methodologies, and much, much more.

The FR project will teach you how to build an automation infrastructure, define a framework for the requirements of the Application Under Test (AUT) .

You will learn about different types of testing including: Regression, Negative, and Sanity (or Smoke) tests.

Page 3: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 3

Subjects/Topics covered

The Object Oriented Programming (OOP) testing methodology.

Build the automation infrastructure. Organizing QTP and test related artifacts a.k.a

Project Folders Define a Global Scripting.Dictionary object. The Application Under Test (AUT). QTP Options. Record and Run Settings configuration.

Page 4: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 4

The OO Testing methodology

First rule : Separate Data from Coding. Second rule : Separate User Interface (UI) from

business logic. Third rule : Business layer module never call another

business layer module, as well as Graphical User Interface (Gui) module never calls another Gui module.

Utils

LayerGUI Layer

Business Layer

Test LayerData

Layer

Page 5: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 5

The Data Layer

The data layer are data source files, thus can be Excel files, xml files or a database.

Utils

LayerGUI Layer

Business Layer

Test LayerData

Layer

Page 6: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 6

The Utils Layer

These are common or specific function libraries associated with the scripts.

Utils

LayerGUI Layer

Business Layer

Test LayerData

Layer

Page 7: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 7

The GUI Layer

Every GUI “Module” handles one GUI screen

Every module handles all the available actions for the current module i.e. Get Data, Set Data, Check Data

Utils

LayerGUI Layer

Business Layer

Test LayerData

Layer

Page 8: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 8

GUI layers schema

G1

G2

G3

G4

G5

Page 9: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 9

Business Layer

The Business Layer supports a single business action. The Business layer module can call 1 to n GUI

modules. The Business module acts like a controller for the

GUI actions. One Business module can never call another

Business module.

Utils

LayerGUI Layer

Business Layer

Test LayerData

Layer

Page 10: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 10

Business Layer illustration

G3

B1

G4

G5

G1

Page 11: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 11

Test Layer The Test Layer is the engine and a procedure to

parse the parameters required for a single test, and call to the required Business Layer Module.

Every Module has a unique name, usually a process name i.e. AddNewCustomer.

The implementation of the test is the same, for all the tests, beside the call to the business action.

Utils

LayerGUI Layer

Business Layer

Test LayerData

Layer

Page 12: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 12

The Infrastructure – Project Folder If you work in a company, you should build

this infrastructure on a network drive /shared drive/version control, with a daily backup.

If You work with Quality-Center the infrastructure should be built within the Test Plan pane.

Page 13: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 13

Mapping a Network Drive for Automation In the real world, we do have network drives. The

best method I know, is to select a constant free drive i.e Q: and map the network drive to the physical location.

By doing this you’ll save large strings paths for example, if you have a network path as the follows:“//server/company/division/project/unit/product/qa/qtp/automation” , map Q: to the automation folder.

All the testers have to do the same. Now, your automation folder is in Q:\FR

Believe me, this process can save you a lot of headaches!!!

Page 14: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 14

Assumptions and Dependencies We are assuming that you don’t have Quality-

Center. We are also assuming that you don’t have a

“network” drive. So, always save your work. A good project starts with a good plan. This step

is skipped assuming that we already have a test plan.

Page 15: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 15

Suggested Infrastructure

LIB

RA

TESTS

RS

DOC

FR

DAT

SETTING

RES

BATCH

ENV

Automation

BL

GL

FR – Flight Reservation Project LIB - Function Library Files RA – Reusable Actions

BL – Business Layer GL – GUI Layer

RS – Recovery Scenarios DOC – Documents DAT – Data Files ( xml, xsl ) SETTING – QTP Settings files. TEST – QTP Tests RES – Results Folder ENV – Environment files BATCH – Batch files from Batch runner or

Multi-Tester Manager

Page 16: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 16

About Reserved Objects

Reserved Objects are QTP COM objects, that extend the capabilities of QTP i.e Reporter, SystemUtil, Parameter, Environment, PathFinder, Description

VBScript objects are not “Reserved”, that’s why you don’t see the intellisense, and all methods and properties when you press the “.”

However, you can insert VBScript objects or any COM object to Reserved Objects.

Page 17: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 17

About Reserved Objects

Inserting objects to reserved category makes QTP to load those objects.

Don’t add unnecessary objects, you’ll pay with performance.

Don’t do it on ADODB; your database will remain always open.

In the next slide we will take the advantage of defining a new reserved object

read more about Reserved Objects here : http://www.advancedqtp.com/2007/06/reserved-objects

Page 18: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 18

GlobalDictionary Object

The OO Methodology needs a data source during run-time.

The solution is to define a Global Scripting.Dictionary Object for this purpose.

If you don’t know what is a Scripting.Dictionary object, please! read related documentation, we are going to use it a lot see link: Scripting QTP - Advanced VBScript

Another advanced option, is to use a disconnected record-set “ADOR.Recordset”; will not covered in this project.

Page 19: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 19

Define a Global Dictionary

Open the Registry editor ( type regedit in run command )

Locate the Key : HKEY_CURRENT_USER\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects.

Close QTP if it’s open.

Page 20: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 20

Define a Global Dictionary

Right Click on ReservedObjects and select from the popup menu New Key

In the newly created entry, type “GlobalDictionary”

Add new String value ProgID = Scripting.Dictionary Right-click on ProgID Modify Scripting.Dictionary ( in

value data ) Add new String value UIName = GDictionary

Right-click on UIName Modify GDictionary ( in value data )

Add a new DWORD value VisibleMode = 2 Right-click on VisibleMode Modify 2 ( in value data )

Page 21: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 21

Define a Global Dictionary

Global Dictionary

Reserved Objects

Key Path

That is how your “ReservedObjects/GlobalDictionaryentry will look.

Page 22: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 22

QTP intellisence for Reserved ObjectsAlways Restart QTP after modifying the Registry

Type GDictionary. In the Expert View, you’ll see the intellisence for the newly created Reserved Object.

Page 23: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 23

Shortcuts...

You can define a .reg file that automatically updates the registry, on any new machine, so you don't have to do it manually.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\GlobalDictionary]

"ProgID"="Scripting.Dictionary"

"UIName"="GDictionary"

"VisibleMode"=dword:00000002

Page 24: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 24

Reg Settings File.

LIB

RA

TESTS

RS

DOC

FR

DAT

SETTING

RES

BATCH

ENV

Automation

BL

GL

ReservedObjects.reg

Page 25: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 25

Recommended Global Objects

GloalFso

You can use a "Log" file during the run-session

DeviceReplay

Simulates mouse and keyboard actions.

Including Drag n Drop

Page 26: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 26

Add-in Manager

Select only ActiveX

Page 27: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 27

The AUT ( Application Under Test ) Our AUT is the Flight Application Demo. The AUT embeds some ActiveX objects. When you first open QTP be sure that only

ActiveX option is checked. Always open QTP before the AUT when working

with ActiveX, otherwise new ActiveX objects will identified as WinObjects.

Only One instance of AUT should be opened while recording.

Page 28: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 28

QTP Global Options

One of the most important options in QTP is to define the working path.

This will allow you to use relative paths when working with tests, resources, data and more.

If for some reason you want to move your project from C:\Automation\FR to D:\Automation\FR you just need to modify a single parameter, otherwise you’ll need to modify all tests, resources and associated repositories… you don’t want to do this, believe me.

Page 29: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 29

Define a Working Path in QTP. Menu : Tools Options Folders Tab Shortcut: Alt + T + O Toolbar

QTP Options

Page 30: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 30

Define the Root Project Folder

Root Project Folder

Page 31: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 31

Recommended Options - Run

Run Mode = Fast

Allow other mercury…

Save still image…

For Errors and Warnings

Page 32: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 32

Recommended Options - General

Display Add-in

manager

Uncheck Automatically generate

“With” statements…

Page 33: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 33

Saving Option Settings

LIB

RA

TESTS

RS

DOC

FR

DAT

SETTING

RES

BATCH

ENV

Automation

BL

GL

Options.vbs

Page 34: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 34

View Options - General

From Menu : Tools View Options

Show line numbers

Auto indent

Tab spacing = 4

Page 35: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 35

View Options – Font and Color From Menu : Tools View Options

Courier New

Size = 10 or 11

Page 36: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 36

Record and Run Settings

When you click “Record” QTP will record anything you’re doing, until you stop recording.

This can be very dangerous; QTP will add new objects to repository and new lines of code.

We can accidentally overload the repository with private objects ( My outlook e-mails ), and with objects we’ll never use.

Solution : Modify Record and Run Settings as explained in next slide.

Page 37: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 37

Record and Run Settings

Menu : Automation Record and Run Settings…

Record and run only on

Applications opened by QTP

Applications specified below

Page 38: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 38

Record and Run Settings

Menu : Automation Record and Run Settings…

Flight4A.exe

Uncheck ”Launch Application”

Include descendant processes

Page 39: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 39

Summary

The Infrastructure for the FR project is ready.

For any question, please refer to the FR Project Forum.

Page 40: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 40

Special Thanks To

Natwarlal Asawa from India, Hyderabad Bharathi Babu from India, Pune Dinkar Singh from India, Delhi Ayyappa Koppolu from India, Pune Paul Grossman from USA, Chicago Sumit Singhal from India, Bangalore Sanjeev Mathur from India, Noida Manasa VN from India, Bangalore Prakash Kumar from India, Pune Suresh K from India, Bangalore Richi Sharma from USA, New Jersey Janardhan Kalvakuntla from USA, New England Joydeep Das from India, Hyderabad

Page 41: FR Project

Dani Vainstein and Monika Arora GautamDani Vainstein and Monika Arora Gautam 41 41

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

@www.AdvancedQTP.com