QTP 8.2 Complete Tutorial

Embed Size (px)

Citation preview

For more QTP Realtime Sripts, visit www.ramupalanki.com Q.T.P. 8.2 ( QUICK TEST PROFESSIONAL) Developed by Mercury Interactive

Functionality Testing Tool

Derived from Win Runner.

Support all Win Runner 7.0 Supported technologies including .Net, XML, SAP, People Soft, Oracle Apps and multimedia technologies.

Records our manual test cases in VB Script

Short navigations to Edit VB Script programs.

Make

QTP

Testing Process:-

Select manual test cases to be automated.

Receive

stable build from development team

Convert

manual test procedures in to VB script programs.

Edit

programs with control statement, Data Driven Test. Statements, Reusable

actions--- etc.

VB Script programs as test batch. After required editing. Run test batches Analyze test results manually.

ADD-IN MANAGER:- These window list out all QTP supported technologies with respect to license.

NOTE:- In QTP, Every test maintains, global excel sheet likes Win Runner. In Win Runner excel sheet opening is explicit, but In QTP Excel sheet opening Implicit.

Recording Modes:- To convert our manual test case procedure into VB Script program. QTP is providing 3 Types of modes. 1. General Recording. 2. Analog Recording. 3. Low level Recording.

(1) General Recording:

For more QTP Realtime Sripts, visit www.ramupalanki.comIn this mode QTP records mouse and Keyboard Operations with respect to Objects and Windows in our application build like as context Sensitive mode in Win Runner. It is a different mode in QTP when you click start recording icon, After click start recording icon, test Engineers can try to browse path of testing build, when he is planning more than one Software to use while creating test. This process is called Selective recording.

(2) Analog Recording: To record mouse pointer movement on the desktop we can use analog recording mode Ex:- Digital Signatures recording, Graphs drawing recording image movement recording. To select this mode, we can use below Navigation. Navigation:- Text menu Analog recording mode (or) Ctrl+Shift+f4

(3) Low Level Recording: In This mode QTP is recording mouse pointer movements on the desktop along with time to select this mode we can use. Navigation :Text menu Low Level recording (or) Ctrl+Shift+F3.

VISIBILITY MODES :-

QTP maintains two types of Visibilities such as 1) Expert View (VB Script)

2) Key word view (English) Expert View: -

Expert view is only allowing Editing and running of the Script.

CHECK PIONTS:QTP is a functionality-testing tool and it provides facilities to automate below Coverages on application build. 1) GUI Coverage or Behavioral Coverage 2) Error handling coverage 3) Input domain coverage 4) Manipulations or out put coverage 5) Back End coverage 6) Service levels coverage

For more QTP Realtime Sripts, visit www.ramupalanki.com7) Links coverage 8) Static text/context coverage. To automate above coverages we can use 7 checkpoints in QTP. (1) Standard checkpoint (2) Text check point (3) Text area checkpoint (4) Bitmap checkpoint (5) Database checkpoint (6) Accessibility checkpoint (7) XML checkpoint

1) Standard Checkpoint: We can use this Checkpoint to verify Properties of Objects like as GUI check

point in Winrunner. Example: - Manual test case.

1) Test case id: TC-id 2) Test case Name: Verify delete button

3) Feature to be test: Flight Reservation 4) Test suite Id: TS-FR 5) Priority: Po 6) Pre-condition: Existing records to be deleted. 7) Test procedure:

Step No 1

Action

I/P required

Expected

Focus to Flight reservation window

-------

Delete button Disabled

2

Open Existing record

ValidOrder No

Delete button enabled

Automation Program:Window (Flight Reservation).Activate Window (Flight Reservation).Winbutton (Delete order). Check Checkpoint ( Delete order). Window (Flight Reservation).WinMenu (Menu). Select File ; open order.

For more QTP Realtime Sripts, visit www.ramupalanki.comWindow (Flight Reservation).Dialog (Open order).WincheckBox (Order No). Set ON Window (Flight Reservation).Dialog (Open order).WinEdit (Edit).Set 1 Window (Flight Reservation).Dialog (Open order).WinButton (ok).Click. Window (FlightReservation).Winbutton (Deleteorder).Check Checkpoint (Delete Order-2)

Check Point Syntax:Window (WindowName).Winobject (ObjectName).CheckCheckpoint (CheckpointName)

Check Point Insertion Navigation:Select Position in Script Insert menu checkpoint

Standard check point select testable object click ok after confirmation Select required properties with expected values click OK. NOTE :-

(a) One check point allows one object at a time unlike WinRunner. b) Check point insertion is possible before click stop recording except database Checkpoint and XMI check point. c) Object selection is mandatory before insert any type of checkpoint. d) Whenever check point is pass (or) fail, but QTP continues test execution up to end.

(e) If any type of Checkpoint inserted into VB Script QTP is showing a common Syntax as above.

Example 2:- Manual test Case:-

Test Case id

:

Tc-2 verify OK button verify employee recruitment Ts_ER Po I/P objects are taking values

Test case Name: Feature to be tested: Test suite ID: Priority: Pre condition Test Procedure

Step no

Action

I/P required

Expected

1 2 3

Focus to Em ployee window Enter Employee Name Select department No

-----Valid value ------

OK button disabled. OK button disabled. OK button enabled.

For more QTP Realtime Sripts, visit www.ramupalanki.com

Build :-

Emp. Name

Dept no

OK

Automation Program:Window (Employee).Activate Window (Employee).Winbutton(ok).check checkpoint (ok) Window (Employee).Winedit (Empname).Set xxx Window (Employee).Winbutton(ok).check checkpoint (ok.2) Window (Employee).Winbutton(Department no).select xxx Window (Employee).Wincombobox(ok).check checkpoint (ok.3)

Note1: Unlike WinRunner every QTP checkpoint is taking two types of expected values form test engineers, such as constant value and parameters (excel sheet column name). Note2: Our checkpoint is executing one tire when our checkpoint expected is constant. Our checkpoint is executing more than one time. Depending on no of rows in excel sheet. (2) BITMAP CHEKPOINT:-

To compare images, we can use this check point. Unlike use QTP is supporting static and dynamic images for comparison. But test Engineers have to select multimedia option in adding manager to compare dynamic images. QTP supports 10 sec. As maximum play time of images.

Example: Logo Testing Old Version New Version

$

$

For more QTP Realtime Sripts, visit www.ramupalanki.comExpected

Actual

= = Pass ! = Fail Navigation:Open old Version of build starting recording open expected image in old version of build Insert menu Check point Bit map Checkpoint show Expected image in old version in build - click OK after confirmation - Select area of image if required Click OK Close old build version Open new build version click run- Analyze result manually.

(3) Database Check Point:We can use this checkpoint to verify the impact front-end operation on backend tables content in terms data validation and data integrate. This checkpoint option is exactly equal to default checkpoint in database checkpoint of Win Runner. Example:

Create database check point (Current content of database tables selected as expected) Valid differences

Perform front-end operation Run database check point (Current content of database tables selected Actual).

To apply data base testing, Test Engineers are collecting below information from development team. connectivity name in between fortend and backend in our application build Names of

tables and their column. Screens vs. Tables. Above information is available Database design document development Team. Navigation:-

Insert menu Check point DB checkpoint Specified connect to DB using ODBC or Data Junction - Select SQL statement manually click Next click create to select connectivity (Ex.Flight32) write select statement click finish click OK after conformation of Database Table content Perform Front-end Operation run Database checkpoint analysis results manually.

( 4) Text Check Point: To verify content of an object in terms of match upper case, lower case ignore spaces exact match and text not displayed, we can use these check points.

Navigation: -

For more QTP Realtime Sripts, visit www.ramupalanki.com

Select position Script Insert menu checkpoint Text checkpoint select Testable

object- click configure if we have to apply testing on selected part object value (using text before and text after)- Select Test (match case, Ignore spaces, exact match , Text not displayed)- click OK.

(5) Text Area Check point: To Verify content of screen area value in terms of match case, ignore spaces, Exact match, Text not displayed, we can use these check point.

Navigation:-

Select position script Insert menu checkpoint Text area check point select value region click OK after conformation click configure if we have to apply testing on selected part Select test to be applied click OK.

Control Statements in VB Script: (a). if Statement :If condition Then --------------End if (b) if else if Statement :

If condition Then --------------Else if condition2 Then --------------Else if condition3 Then --------------Else --------------End if

For more QTP Realtime Sripts, visit www.ramupalanki.com(C) While Loop:While condition ---------------Wend (D)For Loop:For I=1 to n Step 1 ------------Next

(E)Input Statement :Input box (message)

(F)Output statement

Msgbox(message)

(G)Test Result statement:Reporter.ReportEvent 0/1, step name, Description 0 = Pass

1 = Fail

(H) Capture Object value:Option explicit Dim x X= Window (Windownames).Winedit (Objectname ).getvisibletext

Sample Example 1: -

Input Output

xxxx

xxxx

Out put = input *100 Automation Program:-

Option Explicit Dim X, Y Window (Sample).ActivateX=Window (Sample).Winedit (Input).getvisibletext

Y=Window (Sample).Winedit (Output).getvisibletext

If Y = X * 100 Then

For more QTP Realtime Sripts, visit www.ramupalanki.comReporter.Reportevent 0, S1, Pass Else Reporter.ReportEvent 1, S1 fail End if

Example 2:-

Shopping

Inpu t

xxxx

Total = Price * quantity

Automation

Outpu t

xxxx

Program:-

Option Explicit Dim q, p, and tot

Window (Shopping).Activateq=Window (Shopping).Winedit (Quantity).getvisibletext p=Window (Shopping).Winedit (Price).getvisibletext p= mid (P,2 Len (p)-1)tot = Window(shopping).Winedit(total).getvisibletext Tot=mid (tot, 2, Len (p)-1)

If

Cdbl(tot) = Cdbl (p) * q Then Reporter.Reportevent 0, S1 ,calc is pass Else Reporter. ReportEvent 1, S1, calc is fail End if Note: - Variable declaration and type conversion are mandatory tasks in VB script.

To convert text value to numberic we can use Cdbl ( )

To convert numeric into value, we can use Cstr ( )

Data Driven Testing:The re-execution of a test with multiple text data is called data driven testing or retesting or Iterative testing there are 3 types. 1) From Key board 2) From front-End objects 3) From excel sheet.

For more QTP Realtime Sripts, visit www.ramupalanki.comFrom Key board:-

Some times test engineers are re executing VB Script automation depending on multiple input values through dynamic submission using Key board. To read a value from key board input box ( ) Example: - multiply Input 1

Expected:-

Input 2

Result = input 1 * input 2.

OK Result Text data: - 10 pairs of inputs

Automation program:Option explicit Dim I, x, y, r For I = 1 to 10 Step 1 x=input box (Enter input1) y= input box (Enter input2) Window (multiply).Activate

Window (multiply).Winedit (Input1).set X Window (multiply).Winedit (Input2).set Y Window (multiply).Win button (OK).click R = Window (multiply).Winedit (Result).getvisibletext If R = X*Y Then reporter.Reportevent 0, S1, calc is pass Else reporter.Reportevent 1, S1, calc is fail End if Next Example 2:Audit No: of files File-size

OK Xxx KB

Eepected - Total : size Test data - 10 pairs : of

Total size

= No-of-files * filesize.

inputs

For more QTP Realtime Sripts, visit www.ramupalanki.comAutomation program:Option explicit Dim I, x, y, tot

For

I = 1 to 10 Step 1x=input box (Enter no of files) y= input box (Enter file size) Window (Audit).Activate

Window (Audit).Winedit (no of files).set X Window (Audit).Winedit (file size).set Y Window (Audit).Win button (OK).click Tot = Window (Audit).Winedit (Total -size).getvisibletext Tot = mid (tot, 1, Len (tot) 2)

If Cdbl (Tot) = X*Y Then reporter.Reportevent 0, S1, calc is pass Else reporter.Reportevent 1, S1, calc is fail End if Next (2) From Front end objects:Some times test Engineers are re-executing automation programs depending on multiple objects such as list box, menu, table, data window, activex controls.

-----

---------------VB Script Test data Build

Example :Insurance Type

Age

Gender

Qualification

For more QTP Realtime Sripts, visit www.ramupalanki.com

Expected:If Type is A age is focused, If Type is B then gender is focused and if any other Type is Qualification is focused.

Automation program:Option explicit Dim I, x, n Window (Insurance).Activate N = Window(Insurance).Wincombo box(Type).getitemcount For I = 0 to n-1 step 1 X = Window(Insurance). Wincombo box(Type).getitem(i) Window(Insurance).Wincombobox(Type).Select X Ifx = A Then

Window(Insurance).Winedit(Age).Check checkpoint (Age) Else if x = B Then Window(Insurance).wincombobox(Gender).check checkpoint (Gender) Else

Window (Insurance).wincombobox(Qualification).check checkpoint(Qualifiacaion)

End if

Next

STEP GENERATION :-

It is a library of VB Script statement. To search unknown VB script we can follow below

navigation

Navigation: Insert menu Step Step Generator Select category (Functions, test objects, utility objects) Select required operation Fill arguments required Click OK.

(3) FROM EXCEL SHEET:In general Test Engineers are using Excel sheet oriented data driven test to validate completeness and correctness our build functionality with multiple inputs value because QTP is providing a ready made process for these excel sheet oriented data driven test.

For more QTP Realtime Sripts, visit www.ramupalanki.com

From the above model Test Engineers are Populating test data. In excel sheet through import data from database through typing collected data.

Navigation:Populate Test data in Excel sheet convert our manually Test case into automation Program for sample inputs Tools menu Data driver Select sample Input value to Parameterize Click Parameterize Click Next browse excel sheet column name to replace that sample inputs click OK Click finish.

To fill Excel sheet with data base content, Test Engineers are using below navigation.

Navigation:-

Place mouse pointer on Excel sheet Right click Sheet Import From database- Specify connective Select specify SQL statement manually Click Next Click create to select connectivity (Ex:-Flight 32) Write Select statement to import data from base Click finish.

SYNCRONIZATION POINT:After completion of automation program creation with required editing, Test Engineers are concentrating on time mapping in b/w Tool and build to conduct complete testing .They are 3 ways to synchronize Tool and build such as

1) Wait () 2) Properties of object 3) Changes in Settings.

(1) Wait (): -

We can use this function to define fixed waiting time in test Execution.

Syntax:-

Wait (Time in seconds) Wait (10)

(Or) Wait Time in seconds Wait 10

This function defines fixed waiting time out, but our application operations are taking variable time to complete.

(2) Properties of Object:-

We can use this concept to define time mapping between Tool and build with the help of changes in properties of objects in our application build.

Example: - Status (or) Progress bar.

100% color filled out Process completed able to continue Test Execution < 100 color filling In Process continue Wait state.

For more QTP Realtime Sripts, visit www.ramupalanki.comNavigation:Select Position in Script Insert menu Step Syncronization Point Select Status (or) progress bar Click OK after conformation Specified property with Expected value (Enabled True) Specify maximum time in milliseconds Click OK.

Syntax:Window (Window Name).win object (Stausbarname).Wait property Enable, TRUE, maximum time to wait

(3) Changes in settings:Some times our application build is not Supporting wait function and properties of objects like Synconizaiton.In this situation test Engineers are changing the runtime settings of QTP

through below navigation.

Navigation:Test menu Settings Run tab Change timeout form 20.000 milliseconds to more Click Apply Click OK

Above 3 options are require in automation test Execution when our build background operations are taking more than 20,000 milliseconds of time, because QTS is maintaining 20,000 milliseconds as default time out.

BATCH TESTING:In general test Engineers are executing automation program as test batches to increase intension of bugs finding.Every test batch consists of multiple test cases with dependency. One test case End state is base State to next test case, to make batches in QTP .Test Engineers are using below statement.

RUNACTION Action Name [Test name]

Above statement is applicable on Reusable actions only. A program is created as reusable action, which is callable in other programs (or) Invoke able to other program.

xxxx ----------------------------------------------------------------Action S ubTest/R eusabl e

- n -R u n A c tio--- ---x x x x

--------

From the above diagram Test Engineers are giving Reusable action Permission to Corresponding sub test.

For more QTP Realtime Sripts, visit www.ramupalanki.comNavigation:Create automation program individually and same then with Unique test names Open subtest in that programs list (Ex. batch 8a.m) Step menu- Action properties General tab Select Reusable action checkpoint click OKfollow above navigation for all sub Test. To give reusable

action permissionOpen main Test in that programs listInsert menuCall to existing ActionBrowse corresponding Subtest to call in main test.

Parameter Submission:Like as WinRunner, QTP VB Script are also allowing parameters from one to other. Unlike win Runner main test is passing more than one parameter subtest and subtest. is returning more than one output parameters to main test.

Main Test

-------------------------RunAction Action [SubTest], one iteration ---------------------Subtest 10, 20, X, Y

A,I P P aram eters

40O/P Parameters

To create above like i/p, o/p parameters we can follow below Navigation.

Navigation:Open Subtest Step menu Action properties Select parameters tab Create required

no of i/p and o/p Parameters Use that Parameters in required place of Sub test program (Parameter (Parameter Name))

Note: - In QTP Test Engineers are using reusable Actions Concept for repeatable Operation in Build. Instead of user defined function in Win Runner

ADMINISTRATOR OF QTP TESTS.

(1) Paths of files :QTP is maintaining all automation tests in below folder by default.

[C:/program files/mercuryInteractive/QTP/tests/testName (default/name1)]

For more QTP Realtime Sripts, visit www.ramupalanki.com

(2) object repository (or) QTP Architecture:

Like as WinRunner, QTP is also recognize objects and Windows in our application build during recording. In this recognize QTP create Entries for corresponding objects and Windows for future reference.

This all entries are maintaining in a Storage area is called an object repository. This concept exactly Equal to GUI map.

Steps:1 to 3 during Recording 4 and 5 during Running

To see and Edit Recognization entries of objects and Windows, We can follow bellow

navigation.

Navigation: - Tools menu object repository

This repository maintains entries of objects and windows in Per test mode only. Unlike Win

Runner

Note :- No Extension to VB Script program of Entries files. It support only Per test mode. Does not support Global GUI map Entries.

(2) Changes in object Respository:-

For more QTP Realtime Sripts, visit www.ramupalanki.comSome times our application objects (or) Windows Labels are variating depending on given i/p values w.r. to customer requirement. To define common ness on that objects and windows labels test Engineers are following below navigation.

Navigation:Tools menu Object Repository Select corresponding Entry Click Browse Specify Regular Expression Select Regular Expression option Click OK.

Example:-

Logical Name: Fax order NO.1

Logical Name: Fax order NO.1

{Class: Window Label: Fax order No.1

{Class: Window Label: Fax order No. [0.9]

}

}

(4) Virtual object Wizard:Some times the QTP is not able to recognize objects and windows in our application build .Due to the utilization of Advanced Technologies/Unknown Technologies. To recognize that type of object also forcibly. Test Engineers we can follow below navigation.

Navigation :Tools menu Virtual object New virtual object Click Next Select expected type depending on the nature of that non recognized object Click Next Mark that non recognized object area Click Next after conformation Specify logical Name to that virtual object Say yes/no to create multiple Virtual objects Click Finish.

NOTE:QTP maintains Virtual objects information in a storage area is called virtual object manager.

(5) Objects Identification:Some times our application build windows consist of more than one objects as similar. To distinguish this type of objects in test execution. Test Engineers are directing QTP with object identification option in tools menu.

Sample

OK Navigation :-

OK

Tools menu Object identification Select object type Select MSWID (windowId) as assistive property Click OK.

NOTE:Windows operating system is maintaining IDs for Every two objects in our application build.

Logical Name: OK

Logical Name: OK-1

{Class: Pushbutton

{Class: Push button

For more QTP Realtime Sripts, visit www.ramupalanki.comLabel: OK MSWID: xxxx } Label: OK MSWID: xxxx }

REVOVERY SCENARIO MANAGER:This concept is equal to exceptional handling win Runner. Test Engineers are using this concept. To recover form abnormal situation while running test.

QTP allow you to create 4 types of recovery scenario such as

1) POPUP:- To Skip unwanted window (popup means Close window)

2) Object state: To Recover build depending on properties of object (Ex. Status bar)

3) Test Run Error: To Recover from VB script Runtime

4) Application Crash: - To open build when that build crashed.

We can follow below steps to create recovery scenario w.r.t our application builds.

Select type of Recovery Scenario

Define Abnormal Situation in our application build

Select Recovery solution Post Recovery to continue remaining test Execution Define Save Recovery Scenario for Future Reference..

Navigation to Create recovery Scenario:Tools menu Recovery Scenario manage Click New Scenario icon Click Next Select Scenario Type Click Next Enter required details todefine Abnormal situation Click Next Select Recovery type Enter required details to recover

from Abnormal situation Click Next Select Post Recovery type continue remaining test Execution Click Next Enter Scenario Name for future reference Click Finish.

Scenario Type :Any problem related to build defined through 4 types of Scenarios.

(1) Pop up Window :To delete unwanted window which opened during the test run?

(2) Object state : To define problem depending on properties of values of object.

(3) Test Run Error:-

For more QTP Realtime Sripts, visit www.ramupalanki.comTo define problem using Runtime Errors w.r.t VB Script.

(4) Application Crash:To define problem when an open application build fails during the test Run.

Recovery Type:QTP allows you to define 4 Types of recoveries to recover from above defined Scenario

(or) problems.

a) Key board or Mouse Operation :- To defined Recovery

b) Close Application process: To defined Recovery (Ex :EndTask)

c) Function call :- To defined Recovery using Reusable actions in QTP

d) Restart Microsoft windows:- To define Recovery.

Post Recovery Types :After Recovery form specified problem during Test Run QTP allows you to Select Post Recovery Types for remaining test execution. There are 6 Types of Post recoveries such as.

1) Repeat current step and continue. 2) Proceed to Next Step 3) Proceed to Next action (or) Component iteration (Ex batch test) 4) Proceed to Next test iteration means loop (Ex. Data driven test) 5) Restart current test Run 6) Stop the test Run.

For more QTP Realtime Sripts, visit www.ramupalanki.comNOTE 1:- QTP allows you to Export and Import VB Script programs using ZIP process (To store VB Script programs with less amount of space in disk)

NOTE 2: - QTP allows you to Rename Actions in VB Script programs one Action means is a program (or) Path of Program

NOTE 3:- To remove repetation in VB Script statement we can use With statement. Navigation: - Edit menu Apply With statement to Script

Remove with Statement is also possible.

NOTE4:-

Book Marks for Mark in Running

NOTE 5:- Check points are comparing tester given Expected value with Project Actual. But

output value statements are returning output state of object without any comparison.

NOTE 6: QTP test allows you to divide one VB Script program into multiple actions. Navigation:- Insert menu call to New Action

NOTE 7:- QTP 8.2 is supporting Win Runner launching to Run TSL programs. Wise versa is not

possible. Navigation: - Insert menu call to Win Runner Test (or) Function

NOTE 8:- QTP allows you to calculate VB Script execution time using Start and End

Transaction point. Navigation :- Insert menu Start Transaction

NOTE 9:- QTP allows you to debug VB Script program (F11) as short

key. Navigation: - Debug menuNOTE 10:- QTP Supports quality center S/W to save VB Script program permanently.

NOTE 11: Object spy used by test Engineers to identify reorganization of object (or) window. Navigation: - Tools menu Object Spy

WEB TEST OPTION:During web functionality testing, Test Engineers are concentrating on more coverages than generate application functionality testing such as Links Coverage and Static Test Coverages.

To automate these two coverages, Test Engineers are using below check points in QTP

CASE STUDY:Coverage HTML Links (Text link, image Link) XML Links Static text Coverage NOT Applicable get text option XML Checkpoint Text checkpoint ,Text area check point WinRunner7.0 GUI Check point QTP 8.2 Standard check point

For more QTP Realtime Sripts, visit www.ramupalanki.comNOTE 1:- To automate functionality test in web pages we can select web option in Add- In-Manager

NOTE 2:- During Website testing, development team and testing team are working in an

offline mode (offline means Local host (or) Local network)

NOTE 3: QTP is restricting record and own test on specified web site if required.

NOTE 4:- If you create check point on link object, QTP maintains below VB Script maintains.

STATEMENT:-

Browser (Browser Name).page (Page Name).Link (Link Name).check check point (checkpoint Name)

NOTE 5:- Win Runner allows Links testing at one link levels (or) cell Links Levels (or) Page

Links level. QTP supports one Link Level or page Links Level.NOTE 6: QTP Provides Fitter links check in Page Level testing to apply. Check point on all

links (or) Selected links in page.

Statement: Browser (Browser Name).Page (Page name).Check Checkpoint (Checkpoint Name)

NOTE 7: To conduct testing on content of web page, Test engineers are using text check point (or) text area check point. These Check point allows you to apply below test on that selected test.

(1)