91
QUICK TEST PROFESSIONAL (QTP) By Venkata Krishna 06/06/22 Venkata Krishna

Automation Testing Own

Embed Size (px)

Citation preview

Page 1: Automation Testing Own

QUICK TEST PROFESSIONAL(QTP)

By Venkata Krishna

04/07/23 Venkata Krishna

Page 2: Automation Testing Own

Automation Testing:This is the process of testing the application by taking help of any tool is called automation testing.

Ways of Testing:1.Manual Testing2.Automation Testing

When we need to go for automation testing:Whenever we are having number of test cases and need to execute repeatedly, then it require automation testing to overcome below drawbacks of the manual testing.

More resources are requiredMore time is requiredNo accuracyNo repeatabilityNo reusabilityMore budget is requiredTest team may get bored and tiredness

The pre-requisite for automation is application should be stable like more than 70%. (it may vary based on the company)

04/07/23 Venkata Krishna

Page 3: Automation Testing Own

So automation testing is not the replacement for manual testing.To overcome all the drawbacks of manual testing, just it is a continuation to the automation testing.

Why we need to go for automation:Once application is stable then we can continue generating the instructions with the help of any tool.By using tool or automation will give below advantages:

Required less timeLess no. of resources are requiredAccuracyRepeatabilityReusabilityIn the long span of time, budget also gets reduced.

How to work with automation testing:

Application QTP

Test PartnerWinrunner

Instructions

TC’s pass TC’s failTC’s

12304/07/23 Venkata Krishna

Page 4: Automation Testing Own

About QTP

QTP is a graphical user interface functional regression testing tool

Vendor for QTP is mercury interactive and later it was undertaken by the HP in 2006.

Scripting language required for QTP is VB Script . Note: It also supports Java Script.

QTP is used for perform GUI and regression testing.

QTP supports only windows operating system all versions expect window 97.

QTP supports applications like java, .net, web, windows, siebel, SAP, ERP, mainframes, cobol, flex and powerbuilder applications.

QTP supports databases like oracle, SQL server, sybase, mybase, mysql………

QTP supported environments are windows, client-server, web and distributed

The latest version of QTP is 11.0.

04/07/23 Venkata Krishna

Page 5: Automation Testing Own

04/07/23 Venkata Krishna

Different Versions of QTP are 5.5,6.0,6.5,7.0,8.0,8.2,9.0, 9.2, 9.5, 10.0, 11.0

11.0 - Released in 201010.0 - Released in 20099.5 - Released in 20079.2 - Released in 20079.0 - Released in 20068.2 - Released in 20058.0 - Released in 20047.0 - Never released.6.5 - Released in 20036.0 - Released in 20025.5 - First release. Released in 2001

Page 6: Automation Testing Own

Browsers supporting QTP are IE ( all versions ), FireFox 3.5 and QTP 11.0 version is supporting safari also.

Note: Firefox 4.0 will be supported by the QTP but we need to install corresponding patch 6.11.3

ADD-IN Manager:It is a interface between QTP tool and different applications.

By using this window we can tune, different type of applications will get recognize by QTP.

Each type of application will be having specific add-in which we need to get it from the HP and it is licenced.

Default add-ins supported by QTP are VB, ActiveX and Web.

For any other type of application we need to install corresponding add-in then automatically, add-in name will be displayed in add-in manager window.

What are all the add-ins we have selected based on that QTP is going to allow for generating the instructions or identifying the application.

04/07/23 Venkata Krishna

Page 7: Automation Testing Own

Applications NetWebVBJavaOracle appsSAPPeopleSoftSiebelTerminal Emulators

Add-in managerVB

ActiveXWeb Java

QTP

Licenses:

1. Seat License: It can be used in the single system and also it is not possible to share it to the other systems.(Mapped with single system and it is not sharable)

2. Concurrent License: This license can be used by the ‘n’ number of persons simultaneously and also this can be transferrable to other systems.

04/07/23 Venkata Krishna

Support By

Page 8: Automation Testing Own

04/07/23 Venkata Krishna

QTP Installation Procedure:Way 1:

1. Install from QTP.exe ( Trial version for 14 days.) Format is required for every installation. To overcome the same

we need to download QTP Uninstaller.exe from KnowledgeInbox.com site and remove all your registry files and Install again without format also as it will work fine.

Way 2: (Permanent License)1. Install QTP 9.2 with Crack.exe(It will become permanent license)2. Uninstall QTP from Control Panel(Don’t use above QTP

Uninstaller.exe)3. On top of QTP 9.2, Install QTP 10.0 then it will become Permanent

License.

NOTE: Trial for 14 days pop up is not displaying then confirm it is Permanent Version only.

Page 9: Automation Testing Own

04/07/23 Venkata Krishna

Page 10: Automation Testing Own

Controls Windows Web Java

Button Winbutton Webbutton Javabutton

Text field Winedit Webedit Javaedit

Label Static WebElement Label

Dropdown box Wincombobox Webcombobox Javacombobox

Check box Wincheckbox Webcheckbox Javacheckbox

Radio button Winradiobutton Webradiobutton Javaradiobutton

Links ----------- Links JavaLink

Dialog Dialog ------------ Javadialog

Browser ------------- Browser JavaBrowser

Menu WinMenu - JavaMenu

04/07/23 Venkata Krishna

Standard Class Names:

Page 11: Automation Testing Own

Object Repository:QTP is required objects or controls properties information for recognizing the objects/ controls for performing one test case navigation. QTP contains a object repository which is used for maintaining all the object property information for recognizing the object.By default it takes care of all the properties required for identification.

Options:

1. Add objects to local: It is used for adding the application objects along with properties.

2. Highlight in Application: It used for justifying added objects are getting recognized by QTP tool

3. Navigation for Object Repository:

resource object repository

04/07/23 Venkata Krishna

Page 12: Automation Testing Own

QTP Script

1)Button:

Syntax:(Parent window standard type)(parent window object name).(child standard

type)(child object name).operation

Ex: Dialog("Login").WinButton("OK").ClickDialog("Login").WinButton("Help").ClickDialog("Login").WinButton("Cancel").Click

Msgbox Dialog("Login").WinButton("OK").GetROProperty("enabled")Msgbox Dialog("Login").WinButton("OK").GetROProperty("focused")Msgbox Dialog("Login").WinButton("OK").GetROProperty("visible")

04/07/23 Venkata Krishna

Page 13: Automation Testing Own

2. Text Box1. enter/clear2. enabled/disabled3. existence4. verifying entered data5.visible6.focused7. length and width

Ex:

Dialog("Login").WinEdit("Agent Name:").Set "Venkata"Dialog("Login").WinEdit("Agent Name:").Set "“Dialog("Login").WinEdit("Agent Name:").GetROProperty("enabled") ----> True/FalseDialog("Login").WinEdit("Agent Name:").Exist ---> True/FalseDialog("Login").WinEdit("Agent Name:").GetROProperty("text") ---> Get entered valueDialog("Login").WinEdit("Agent Name:").GetROProperty("visible") ---> True/FalseDialog("Login").WinEdit("Agent Name:").GetROProperty("focused") ---> True/FalseDialog("Login").WinEdit("Agent Name:").GetROProperty("length")Dialog("Login").WinEdit("Agent Name:").GetROProperty("width")

04/07/23 Venkata Krishna

Page 14: Automation Testing Own

3. List Box/combobox

1. Select item name/index2. Get All items / Get Content3. Get current selected item4. Get item count5. enabled6. Focused7. visible8. Exist

Window("Flight Reservation").WinComboBox("Fly From:").Select "London" Window("Flight Reservation").WinComboBox("Fly From:").Select 2

msgbox Window("Flight Reservation").WinComboBox("Fly From:").GetROProperty("all items")

msgbox Window("Flight Reservation").WinComboBox("Fly From:").GetContent

msgbox Window("Flight Reservation").WinComboBox("Fly From:").GetROProperty("text")msgbox Window("Flight Reservation").WinComboBox("Fly From:").GetSelection

04/07/23 Venkata Krishna

Page 15: Automation Testing Own

04/07/23 Venkata Krishna

msgbox Window("Flight Reservation").WinComboBox("Fly From:").GetItemsCount

msgbox Window("Flight Reservation").WinComboBox("Fly From:").GetROProperty("enabled")

msgbox Window("Flight Reservation").WinComboBox("Fly From:").GetROProperty("focused")

msgbox Window("Flight Reservation").WinComboBox("Fly From:").GetROProperty("visible")

msgbox Window("Flight Reservation").WinComboBox("Fly From:").Exist

Note: Above all methods will be same for list box in both WINDOWS or WEB applications.

Page 16: Automation Testing Own

4. CheckBox

1. Set2. deselect3. enabled4. exist5. checked or not6. focused

window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer Name").Set "ON"window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer Name").Set "OFF"window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer Name").GetROProperty("enabled")Msgbox window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer Name").Existmsgbox window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer Name").GetROProperty("checked")msgbox window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer Name").GetROProperty("focused")

04/07/23 Venkata Krishna

Page 17: Automation Testing Own

04/07/23 Venkata Krishna

5. Radio Button:

1. set radio button2. Verify Checked3. Exist4. visible5. enabled

Window("Flight Reservation").WinRadioButton("First").Setmsgbox Window("FlightReservation").WinRadioButton("First").GetROProperty("checked") ---> ON/OFFmsgbox Window("Flight Reservation").WinRadioButton("First").Existmsgbox Window("Flight Reservation").WinRadioButton("First").GetROProperty("visible")msgbox Window("FlightReservation").WinRadioButton("First").GetROProperty("enabled")

Page 18: Automation Testing Own

04/07/23 Venkata Krishna

6. Menu:1.Exist2.Select

msgbox Window("Flight Reservation").WinMenu("Menu").Exist

Window("Flight Reservation").WinMenu("Menu").Select "File;New Order“Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..."

Page 19: Automation Testing Own

7. Browser:

1. open2. exist3. close4. Full Screen5. Refresh6. maximize/ minimize7. activate

Ex:Systemutil.run “IEXPLORER.EXE”, “URL”Msgbox browser (“orange hrm”). ExistBrowser (“orange hrm”). CloseBrowser (“orange hrm”). Fullscreen Browser (“orange hrm”). refresh

Strhwnd = browser (“orange hrm”). Getroporperty (“hwnd”)Window (“hwnd:=“&strhwnd). MaximizeWindow (“hwnd:=“&strhwnd). MinimizeWindow (“hwnd:=“&strhwnd). Activate

04/07/23 Venkata Krishna

Page 20: Automation Testing Own

8. ACTIVEX:

1. Type2. Enabled3. visible4. Retrieve activex field value

Window("Flight Reservation").ActiveX("MaskEdBox").Type "111111"msgbox Window("Flight Reservation").ActiveX("MaskEdBox").GetROProperty("enabled")msgbox Window("Flight Reservation").ActiveX("MaskEdBox").GetROProperty("visible")msgbox Window("Flight Reservation").ActiveX("MaskEdBox").GetROProperty("text")

04/07/23 Venkata Krishna

Page 21: Automation Testing Own

04/07/23 Venkata Krishna

9. Page:1. exist Browser (“orange hrm”). Page (“orange hrm”).Exist

10. Frame:1. existBrowser (“orange hrm”). Page (“orange hrm”).Frame(“Orange hrm”).Exist

11. Link:1. click 2. exist

Browser (“orange hrm”). Page (“orange hrm”). Link (“change password”). Click

Msgbox Browser (“orange hrm”). Page (“orange hrm”). Link (“change password”). Exist

Page 22: Automation Testing Own

Object Spy:It is the feature used for checking the object properties hold by the controls available in our application.Object spy display the specific objects, property names and property values, but where as object repository is used for storing the objects, mandatory properties for recognizing the objects.

Utility Statement:It is used for opening the application or executing the exe’s. We need to specify type of browser as a first argument to the utility statement along with path as second argument for opening the web application with specific browser.Whenever we need to work with windows application, then we need to specify exe file path.

Systemutil.run “browser”, “path”Systemutil.run “path”

Ex: systemutil.Run "chrome.exe","www.gmail.com"

04/07/23 Venkata Krishna

Page 23: Automation Testing Own

Types of Objects:

There are 2 types of objects available in any application1. Test Objects:Objects which are static(Constant).These Objects all Properties and their values are not going to change in runtime.

Ex: Labels,Menus….

2. Runtime Objects:Any Object property values are getting changed in runtime then those all objects are

Runtime Objects.Any property value may get changed based on operation performed on our applcation for

these objects.

Ex: Button,text field,Drop down box, checkbox,radiobutton…..

04/07/23 Venkata Krishna

Page 24: Automation Testing Own

Object Methods:

1. Getroproperty:It is used for fetching the runtime object property value. Objects may have n no of properties, Whenever we require to fetch any runtime property value then we can fetch using this property.

2. Select: It is used for selecting the particular item from the combo box ,drop down list box and also selecting items in Menu.

3. Click:It is used for clicking on the button, link.

4. Set:It is used for set the data into test field and clearing the data. It is used for check checkbox by providing the arguments ON and OFF.

5. Type:It is used for type the particular data into text field / ACTIVEX.

6. Maximize: It is used for maximizing the window or dialog or browser.04/07/23 Venkata Krishna

Page 25: Automation Testing Own

7. Minimize:It is used for minimizing the window or dialog or browser.

8. Activate:It is used for activating the dialog or window or browser.

9. Exist:It is used for checking the control or objects availability. If it is available it will return true, else false.

10. Close:It is used for closing the existing window or dialog or browser on our desktop.

04/07/23 Venkata Krishna

Page 26: Automation Testing Own

11. Fullscreen:It is used for fullscreen the browser window.

12. Refresh:It is used for refreshing the specific browser window.

13. Gettoproperty:It is used for fetching the test object properties, it means the properties and their values are constant while developing the instructions and while executing the instructions.

Note: Getropropety is used for fetching the not only runtime object properties but also test object properties as well.

04/07/23 Venkata Krishna

Page 27: Automation Testing Own

Recording Modes:There are 3 types of recording modes which will allow us to perform actions on our application and parallely QTP will generate instructions or script for the automation engineering.

1.Normal Recording Mode:It will record the script based on the actions on our application by adding worked objectsinto object repository. It is the default recording mode it will recognize the objects basedon properties stored in object repository.

automation

record

2. Analog Recording Mode:This is used for recording the script for the actions on our application, it will providesecurity to the instructions. It will not show recorded script to the automation engineer,but it will perform all the recorded operations.There are 2 types of analog recording levela.Record relative to the screenb.Record relative to the window

04/07/23 Venkata Krishna

Page 28: Automation Testing Own

a) Record relative to the screen:In record relative to the screen will record the instructions based on the screen

coordinates.If at all window place is changing on our screen, then it will not perform action recorded.

b) Record relative to the window:It will record the instructions or script based on the window coordinates. If at all windowlocation is changed on our screen, it will perform all the recorded actions.

3. Low Level Recording:It is used for recording the script based on the actions performing on our application, but itwill recognize the control using their coordinates.If at all object coordinates or object location is changing then it is not going to perform therecorded action due to the change in object location.

04/07/23 Venkata Krishna

Page 29: Automation Testing Own

VB Script It is a light weight programming language Microsoft is the vendor for VB Script VB Script is used for verification purpose along with QTP.

Note: We can use VB Script for developing the web application along withHTML.

Variable:It is name of the memory location in RAM. By using this name we can keep test data andwe can fetch whenever we require while executing the instructions.

strnamesirivenkatintage

04/07/23 Venkata Krishna

Page 30: Automation Testing Own

Declaration of Variable:

By using this we can update memory cell name or variables names to the QTP tool.We have to use the keyword ‘DIM’ ( dimension ) for declaring the variable. It is not mandatory to declare a variable in VB Script, but to overcome the unexpected results with the misspelled variables or we have to declare every variable along with option explicit statements.

Option Explicit:It is the statement used for finding the undeclared variables in our instructions. It will throw an error whenever it finds any variable is not declared.

Ex: option explicitDIM strinstnameDIM intageDIM fltweightstrinstname = “siri”intage = 50fltweight = 10.5msgbox strinstnamemsgbox intagemsgbox fltweight

04/07/23 Venkata Krishna

Page 31: Automation Testing Own

Operators:

1. Arithmetic:+, -, *, /, %

2. Assignment:=

3. Logical:And , Or and Not

4. Concatenation:&

Ex: strname1 = “venkat”strname2 = “krishna”strfullname = strname1 & “_” & strname2 msgbox strfullname

04/07/23 Venkata Krishna

Page 32: Automation Testing Own

Conditional Statements:

There are 2 types 1.If statement2.Select case statement

1. If Statement:This is classified into 3 types1.Simple If end if2.If else end if3.Nested if else end if

Note: These statements are used for verifying the application behaviour based on the actions done on our application.

Syntax:

1) If (condition) then……………..…………..End if

04/07/23 Venkata Krishna

Page 33: Automation Testing Own

2) If (condition) then……………….……………..Else…………………….End if

3) If (condition) then……….……….Else if (condition) then…………………………Else if (condition) then………….…………Else……………………End if

04/07/23 Venkata Krishna

Page 34: Automation Testing Own

Ex:Systemutil.run “URL”If dialog (“login”). Exist then

Msgbox “dialog window opened successfully”)Else

msgbox (“dialog window not opened”)End if

Ex: Intvalue = 5If intvalue < 5 then

msgbox “value is less than 5”Else if intvalue < 10 then

msgbox “value is less than 10”Else if intvalue < 15 then

msgbox “value is less than 15”Else

msgbox “value is more or equal to 15”End if

04/07/23 Venkata Krishna

Page 35: Automation Testing Own

2. Select Case

Select condition/ expectedCase 1:

………………

Case 2:………..……….

Case N:……………………..

End select

Ex:I = 15Select case ICase 1: msgbox “value is 1”Case 2: msgbox “value is 2”Case 10: msgbox “value is 10”Case 15: msgbox “value is 15”End select

04/07/23 Venkata Krishna

Page 36: Automation Testing Own

Looping Statements:These are used for preparing the set of statements repeatedly based on test cases functionality.If we know starting and ending points for executing statements fixed number of times then you can use for loop.If we don’t no starting and ending points but we have to execute set of statements repeatedly based on the condition or assignment, then have to use while loop.

For Loop:Syntax:

For (Start) to (End)…………..………….Next

Ex: for i=10 to 100I = I + 1msgbox Inext

o/p: 11, 13, 15, 17,……………………., 99

04/07/23 Venkata Krishna

Page 37: Automation Testing Own

While LoopWhile loop is classified into 4 types

1.Do While Loop2.Do Loop While3.Do Loop Until4.Do Until Loop

Do While Loop:

Syntax:do while ( condition )…………..………….loop

Ex:i=30

Do while (i>20)i = i-1msgbox i

Loop

04/07/23 Venkata Krishna

Page 38: Automation Testing Own

Do Loop While:

Syntax:do…………..…………….loop while ( condition )

Ex:I = 30doI = I – 1msgbox Iloop while ( I < 20 )

o/p: 29, 28, 27, ………………….., 21

Note: Do Loop While and Do While Loop are going to execute set of statements repeatedly till the condition becomes false.

04/07/23 Venkata Krishna

Page 39: Automation Testing Own

Do Loop Until:

Syntax:do ……………………………………loop until ( assignment )

Ex: I = 10doI = I + 1Msgbox ILoop until ( I = 20 )

o/p: 11,12, 13,……………………., 20

04/07/23 Venkata Krishna

Page 40: Automation Testing Own

Do Until Loop:

Syntax:do until ( assignment )…………………………….loop

Ex:I = 10do until ( I = 20 )I = I + 1msgbox Iloop

o/p: 11, 12, 13,……………………, 20

Note: Do loop until or do until loop statements are going to execute set of statements repeatedly till the condition becomes true.

04/07/23 Venkata Krishna

Page 41: Automation Testing Own

Synchronization:

These are all the used for verifying the application behaviour or status we need to manage QTP tool for performing instructions operations based on the application status.We can work with sync method with the web applications, but where as in windows applications we have to use wait and exist methods.Note: exist method will be applicable for all the controls.

Msgbox dialog(“cannot find server”). Exist (10)Browser (“cannot find server”). Sync Wait 100

Exist method will verify for every second till it reach the specified time.

In wait, till application loaded it will wait for ‘n’ number of seconds. It will constantly waits for specified number of seconds.

04/07/23 Venkata Krishna

Page 42: Automation Testing Own

04/07/23 Venkata Krishna

FunctionsIt is containing collection of statements used for performing the particular tasks or operation.It can allow us to reuse by passing multiple arguments.Wherever we need to use same set of statements, we can make a call to function.

Types of Arguments:Parameters which we are passing to the function is called arguments.These are 2 types1.Input arguments2.Output arguments

Input arguments are passed to the function from calling environment and output arguments are returned from the called environment to the calling environment.

Syntax:Function ( function name ) { arguments }…………………………………………………………………….End Function

Page 43: Automation Testing Own

04/07/23 Venkata Krishna

Note: Function is differentiating input and output arguments using byval and byref keywords.Byval is used for specifying it as a input arguments.Byref is used for specifying it as a output arguments.

Syntax:Function ( function name ) [ byval {argument name}, byval {argument name}, …, byref {argument name}, ……………. ]………………….……………………………………………End Function

Advantages of working with functions:1.Reusability2.Development time will be saved3.Easy maintenance4.Modularity Creating Functions:We need to identify input and output argumentsWe need to provide function definitions.

Page 44: Automation Testing Own

04/07/23 Venkata Krishna

Ex:Call login("suresh","mercury“, blnstatus)msgbox blnstatus

Function login( byval strname, byval strpwd, byref blnstatus) systemutil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe" If dialog("Login").Exist Then

dialog("Login").WinEdit("Agent Name:").Set strname dialog("Login").WinEdit("Password:").Set strpwd dialog("Login").WinButton("OK").Click

End If wait 5 If window("Flight Reservation").Exist (5) Then

blnstatus = trueelse

blnstatus = false End IfEnd Function

Page 45: Automation Testing Own

04/07/23 Venkata Krishna

Ex:blnstatus = login ("suresh","mercury“,)msgbox blnstatus

Function login( byval strname, byval strpwd) systemutil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe" If dialog("Login").Exist Then

dialog("Login").WinEdit("Agent Name:").Set strname dialog("Login").WinEdit("Password:").Set strpwd dialog("Login").WinButton("OK").Click

End If wait 5 If window("Flight Reservation").Exist (5) Then

login = trueelse

login = false End IfEnd Function

Note: From where the function definition will be there, we are calling this as a calling environment.

Page 46: Automation Testing Own

04/07/23 Venkata Krishna

How to make a call to function

Syntax:call functionname ( arguments )Variable = functionname ( arguments )

Ex: 1) Call login("suresh","mercury“, blnstatus)

2) blnstatus = login ("suresh","mercury“,) msgbox blnstatus

Creating Libraries:We have to copy or place all the functions into notepad file and save with .vbs extension then it will become a vbscript library.We can place ‘n’ number of functions into one library. ( there is no restrictions for placing the no. of functions )

Page 47: Automation Testing Own

04/07/23 Venkata Krishna

Associating library file to QTP tool:We have to map library file to the QTP tool so that we can reuse same function in multiple areas.We have to attach this library file to below path

File

Setting

Resource

Associate the file to library ( navigate to library path )

In Built Functions:1.Lcase2.Ucase3.Trim4.Ltrim5.Rtrim6.Len7.Instr8.Cstr9.Cint10.Mid

Page 48: Automation Testing Own

04/07/23 Venkata Krishna

1. Lcase:It will convert all the uppercase strings into lowercaseEx:

strname = “KRISHNA”msgbox lcase (strname)

2. Ucase:It will convert all the lowercase strings into uppercaseEX:

strname = “krishna”msgbox ucase (strname)

3. Trim:It is used for removing the spaces at the begin and end of the given string.Ex:

strname = “ KRISHNA ”msgbox trim (strname)

4. Ltrim:It is used for removing the spaces only at the beginning of the string.Ex:

strname = “ KRISHNA”msgbox ltrim (strname)

Page 49: Automation Testing Own

04/07/23 Venkata Krishna

5. Rtrim:It is used for removing the spaces at the end of the string only.Ex:

strname = “KRISHNA ”msgbox rtrim (strname)

6. Len:It is used for finding the length of the given string.Ex:

strname = “ KRISHNA ”msgbox len (strname)

7. Instr:It is used for finding the one string exsistency in another string.

Syntax:instr ( starting char no, first string, search string )strfirst = “venkat krishna”strsecond = “krishna”msgbox instr ( 1, strfirst, strsecond )

Page 50: Automation Testing Own

04/07/23 Venkata Krishna

8. Cstr:It is used for converting any integers or floats into string formatEx:

msgbox cstr (10)

9. Cint:It is used for converting any string into integer format.Ex:

msgbox cint (“10”) + 10

10. Mid:It is used for fetching the substring from another string by using the starting char and after that no. of charsEx:

strfirst = “venkat krishna”msgbox mid (strfirst, 4, 5)

Page 51: Automation Testing Own

04/07/23 Venkata Krishna

QTP PANESQTP is having total 7 panes which we use for developing the enhance level of instructions.

1.Test Pane:It is used for writing the instructions or script by the automation engineer. This pane is classified into 2 types:

a) Expert View: This is the place where we can enter our instructions in QTP tool and it will allow us to perform the execution as well.b) Keyword View: It will display all the expert view statements in the keyword form. It is used for non-technical persons for maintaining the instructions.It will show instructions in 4 sections those are item, operation, value and documentation.

2. Data Table:It is used for maintaining the test data. It will allow us to import and export data from othersources based on test data requirements.

3. Active Screen:It is used for storing the images of applications by highlighting the corresponding controlwhich we are working in recording. This pane will be displaying images only forinstructions developing from recording mode.

Page 52: Automation Testing Own

04/07/23 Venkata Krishna

4. Debugger View:Debugging: It is the process of resolving the script issues or errors getting while executing the script. This pane is used for doing the debugging process.We can find solutions for the script issues using this pane.

5. Missing Resources:It will display the missing resources such as library file, shared object repository and so on whenever we missed to associate the same.

6. Information Pane:By using this pane we can store the any information regarding or test case or standards. It is only used for information to the automation engineer.

7. Information Pane:It will display all the associated files to the automation engineer.Ex: files are libraries, shared object repository, etc.,

Page 53: Automation Testing Own

04/07/23 Venkata Krishna

ACTIONSThere are 3 types of actions1.Normal2.Reusable3.ExternalNote: Actions are used for reducing the script complexity. Using reusable actions we can get the reusability and also maintenance will easier.

Creating Normal Actions:Insert

Call to new action

Normal reusable

Note: for converting reusable action into non-reusable action by unchecking reusable action option.

Page 54: Automation Testing Own

04/07/23 Venkata Krishna

Right click on action

Action option

Click on action properties

In action properties uncheck reusable action

Inserting Reusable Action:

Insert

Call to new reusable action

Action will be added into script

Action Properties

Reusable Action

Page 55: Automation Testing Own

04/07/23 Venkata Krishna

Creating the External Action:We can create external action only for reusable action.We can pass multiple input and output arguments. For fetching the parameter values into external action. We have to use “parameter” syntax.We have to use reusable action and specify arguments, save reusable action, call reusable action from other location (external action).

Called Environment or External Action Definition:

Struname = parameter (“strusername”)Strpassword = parameter (“strpwd”)Strpath = parameter (“strpath”)

Systemutil.run strpath

If dialog(“login”).exist then dialog(“login”).winedit (“agentname”).set struname dialog(“login”).winedit (“password”).set strpwd dialog(“login”).winbutton (“ok”). ClickEnd if

Page 56: Automation Testing Own

04/07/23 Venkata Krishna

If window (“flight reservation”). Exist(10) then parameter (“blnstatus”) = trueelse parameter (“blnstatus”) = falseEnd if

Calling Environment or Reusable Action Call

Insert

Call to existing action

Strflightpath = “url”Runaction “login [login_ra]”, oneiteration, “suresh”, “mercury”, strflightpath, blnstatusMsgbox blnstatus

Ok

Browse to reusable action

Page 57: Automation Testing Own

04/07/23 Venkata Krishna

Call to copy of action

Insert

Call to copy of action

Click on ok

Note: External actions are in read only mode in the calling environmentWe can edit or modify the external action by opening the action definition.When we want to edit some part in external action and use for your test case then we can use call to copy of action. It will allow us to edit or modify in the calling environment.

Runaction “copy of login”, oneiteration, “venkat”, “mercury”, blnstatusMsgbox blnstatus

Select of action

Ok

Browse

Page 58: Automation Testing Own

04/07/23 Venkata Krishna

Split:Using this we can split one action into two actions based on the cursor positionWe can split one action into multiple actions by doing split multiple times

Note: to reduce the complexity of test script we can split into multiple actions.

OBJECT REPOSITORY:

Repository is of 2 types1.Local object repository2.Shared object repository

Local object repositoryIt is local to the particular script. What are all the updates/changes done on object repository will be restricted to the same script.We cannot reuse local objects in other scripts.

Note: if at all the test cases are having different functionalities then we have to use local object repository

Page 59: Automation Testing Own

04/07/23 Venkata Krishna

1. Create from local objects2. Directly from ORM

Note: shared object repository is the place where it will allow add the objects into repository and map the same to the ‘n’ number of scripts.

Advantages:ReusabilityOvercome the redundancy/duplicationMaintenance will be easier

Create from local objects:Open local OR

File

Export local objects

Browse

.tsr (test shared repository)Ok

Page 60: Automation Testing Own

04/07/23 Venkata Krishna

Resources

Associate repositories

Open/update SOR

Resources

Object repository manger (ORM)

File open browse to OR path

Open in read only mode

Click on enable editing for modify/update

Available AssociateAction1Action2

Browse

Ok

Page 61: Automation Testing Own

04/07/23 Venkata Krishna

Directly from ORM

Resource

Object Repository Manager

Add objects

Save .tsr

Associate repositories

Page 62: Automation Testing Own

04/07/23 Venkata Krishna

Descriptive Programming:We are not using OR for developing the instructions.The properties required for identifying the objects we are going to keep directly in our instructions.Without having the application we can generate the instructions parallel to the development phase by taking all the object properties from development team.

Note: 1) Based on client request we can proceed with descriptive programming.2) Whenever any object properties are keep on changing based on the input data then we can manage using descriptive programming.

Advantages:Execution will be faster compared to using OR.Managing the runtime objects which properties are frequently changing.

Managing runtime objects:

100

result

Add

Page 63: Automation Testing Own

04/07/23 Venkata Krishna

Descriptive Programming Instructions

If dialog(“text:=login”, “nativeclass:=#32770”). Exist then dialog(“text:=login”, “nativeclass:=#32770”). Winedit (“class:=edit”, “text:=agentname”). set “venkat” dialog(“text:=login”, “nativeclass:=#32770”). Winedit (“class:=edit”, “text:=password”). set “mercury” dialog(“text:=login”, “nativeclass:=#32770”). Winbutton (“class:=button”, “name:=ok”). ClickEnd if

Regular Expression:It is used for regularise the properties of the objects. If at all property value is getting changed frequently then we cannot manage working with same object again by storing it in object repository. To overcome above problem we have to make common part to recognize the object by ignoring the change part.

ok

Name

Login

Venkat

Venkat .* In OR make venkat 100 as .*

Page 64: Automation Testing Own

04/07/23 Venkata Krishna

Navigation:

Resources

ORM

class

properties

Webedit

Click on Button

………..

ok

Regular expression

Value configuration options

Page 65: Automation Testing Own

04/07/23 Venkata Krishna

Regular Expressions in DP:

Window (“text:=“, “native class”)Dialog (“text:= faxorder.*”, “native classs:=#32770”). exist

We can use regular expressions in Dp for recognizing the object by making regularize.We have to enter .* for the changing part same like OR.

BATCH RUNS:In realtime we are performing all the scripts execution unattendly, it means executing the script without any user intervention (interaction).We are running the script from QC as it will maintain all the scripts along with the executed results.We should not use message box in realtime scripting, we can use for output verification while developing the instructions but we should ensure no message boxes at the time of storing into QC.We should user reporter statements for finding the test script results.

Syntax:Reporter.Reporterevent

Page 66: Automation Testing Own

04/07/23 Venkata Krishna

Ex:If dialog (“login”).Exist then

reporter.reporterevent micpass, “verifying login window”, “login success” else

reporter.reporterevent micpass, “verifying login window”, “login not success”End if

Transactions:For finding the application performance using QTP, we have to use transactions. We have to insert transactions at some point or step in our script and we have to end at some step then it will provide script execution time or transaction time will be provided for the statements between start and end transactions.

Navigation:insert

start transaction / end transaction

Page 67: Automation Testing Own

04/07/23 Venkata Krishna

Ex:Service.StartTransaction “sample”WaitIf dialog(“login”).exist then

reporter.reporterevent micpassElse

reporter.reporterevent micfailEnd ifService.EndTransaction “sample”

Environment Variables:Based on the environment such as UAT, preproduction, production, environment data may be changed to maintain all our script execution on multiple environments we have to use environment variables.It is a global file, it means we can access the variable values from all over test packIt is a XML file, we can generate XML file from userdefined environment variables by exporting internal environment variables.

Environment variables are 2 types:1.In-built2.User-defined

Page 68: Automation Testing Own

04/07/23 Venkata Krishna

In-built: These are provided by QTP for retrieving the testing machine specifications.ex: Action name, OS, OS Version, temp directory, etc.,

User-defined: Based on our requirement if at all any data is changing based on the environment, we can define environment variables in environment tab under resources option.Once we exported all the above become external, it means we can use these variables anywhere in our script.

Navigation:file

settings

environmentSyntax:

<Environment><variable>

<name>………….</name><value>…………. </value>

</variable></Environment>

Page 69: Automation Testing Own

04/07/23 Venkata Krishna

Associating Environment Variable File:file

settings

environment

variable type (user defined)

check the load variable checkbox

import the created XML file

click on apply

ok

Accessing the environment variable data:Environment.value (“variable name”)

Ex: Environment.value (“OS”) In-builtEnvironment.value (“strusername”) User-defined

Page 70: Automation Testing Own

04/07/23 Venkata Krishna

Data Table:It is used for maintaining the runtime data by taking this we can execute our script that many no. of times.It will maintain the data temporarily while executing, after execution this data will disappear. We can import and export data from external files, so that we no need to maintain test data along with scripts.

Syntax:Datatable.value (“colname”, datatable type)It is used for retrieving from data table

Ex:Datatable.value (“A”, Global)

Page 71: Automation Testing Own

04/07/23 Venkata Krishna

Methods of DataTable:

1.Import: It is used for importing the data from excel (.xls) sheet. It will import all the sheets data into available datatables in our script.Ex: DataTable.import ( “ excel path” )

2.Import Sheet: It is used to import specific sheet data into data table.Ex: datatable.importsheet (“filepath”, “sheet id/name”, “destination id/name”)

3.Add Sheet: It will add the new sheet into data tableex: datatable.addsheet (“name of the sheet”)

4.Delete Sheet: It will delete the existing sheet from the data tableEx: datatable.deletesheet (“sheet id/name”)

5.Export: It is used for exporting the data from our script from all the data tables into specified location.Ex: datatable.export(“path of file destination”)

6.Export Sheet: It is used for exporting the specific datatable data in our scriptex: datatable.exportsheet (“destination path”, “global/action”)

Page 72: Automation Testing Own

04/07/23 Venkata Krishna

7.Get Current row: It is used for getting the active row from the data table.Ex: datatable.getcurrentrow (global)

datatable.getsheet(“sheet name”).getccurrentrow.

8.Get Row Count: It will give the rows count of data tableEx: datatable.getrowcount

datatable.getsheet(name of sheet).getrowcount

9.Get Sheet count: It will give all the sheets counts in our script available in data table.Ex: datatable.getsheetcount

10.Set Current Row: It will make the specific row as active rowEx: datatable.setcurrentrow (“row number”)

11.Set Next Row: It will set the immediate next row as active rowEx: datatable.setnextrow

12.Set Prev Row: It will set the previous row as active rowex: datatable.setprevrow

13.Value: It is used for retrieving and updating the value into the datatable.Ex: datatable.value

Page 73: Automation Testing Own

04/07/23 Venkata Krishna

14.Raw Value: It is used for fetching the formulae of specific field or cell in our data table.Ex: datatable.rawvalue

Object Identification:Objects will be identified by using QTP based on no. of properties.Object identification is the place where we can manage our properties of all the controls which are adding into the object repository.Here it will display all the controls of all the supported environments.If at all any control type is not getting recognized using default properties then we can edit below properties and try to make QTP to recognize the object.

1.Mandatory2.Assistive3.Base Filter4.Optional Filter5.Ordinal Identifiera.Location b.Index

Page 74: Automation Testing Own

04/07/23 Venkata Krishna

Smart Identification:If at all object is not recognized using default properties such as mandatory and assistive then based on the selection of smart identification it will use the base filter and optional filter properties.

Ordinal Identifier:It is used for uniquely recognize the object using index and location.1) Index: Whenever any object is having unique no. then automatically QTP will use that for recognization.

2) Location: It will use the default coordinates of particular object for recognization.

Note: 1) Based on the selection of either index or location of specific control it will use for recognizing the object.2) In real time mostly we use to work with index whenever any object is not recognized.

Page 75: Automation Testing Own

04/07/23 Venkata Krishna

Debugg Viewer Pane:It is the process of executing instructions with the intention of finding script errors.This pane is used for doing the debugging process effectively

Breakpoint:This point is used for stopping the script execution temporarily.Place the cursor where need to insert break point.

Debug

Insert / remove breakpoint option

Note: By using the mouse left button, click on left side to our script statement will insert the break point.

Debug Viewer Pane option:Watch: This is used to watch required variable along with their values.

Variables: It will contain all the variables and their data will be displayed, it will allow us to modify the data as well.The changed data will get reflected in all the places in our script.

Page 76: Automation Testing Own

04/07/23 Venkata Krishna

Command: It will allow us to execute the instructions and we can observe the results.

Debugging Keywords:Step into: It will take control to the inside of the function and will allow us to execute all the statements line by line.

Step over: It will over come functions and reusable actions, will execute all the instructions line by line.

Step out: It is used to moving control out of function or reusable action.After step out control will move to the immediate next statement after function call or reusable action call.

Debug from step: It will perform script execution in debugging mode.

Page 77: Automation Testing Own

04/07/23 Venkata Krishna

Check Point:It is used for verifying the existency of all the controls.We can insert check points only in recording mode.Irrespective of object properties available in object repository.Check point will store required properties into object repository.Due to this OR size is getting increased it leads to performance issue.

Insert

Checkpoint

(standard, text, bitmap, text area, database,………..)

Output Values:It is used for exporting the object properties and their values into data table.We can use these properties for our future references.

insert

output valuesNote: we can insert o/p values only in recording mode.

Page 78: Automation Testing Own

04/07/23 Venkata Krishna

Check point:

Properties OR AVT

Output value:

AVT

Datatable

Page 79: Automation Testing Own

04/07/23 Venkata Krishna

File System Object:It is used to work on file system such as creating files, folders and delete files, folders.It will allow us to perform all the manual operations on file system through script.All these operations performing with predefined methods provided by file system object. Hence we have to create reference for the same.

Set FSO = create object (“scripting.filesystemobject”)

Methods:Create folderCreate fileDelete folderDelete fileFile existsFolder existsCreate text file

Ex: ///// create foldeSet FSO = create object (“scripting.filesystemobject”)If NOT FSO folder exists (“c:\new object\siri”) then

FSO.createfolder (“c:\newfolder\siri”)End if

Page 80: Automation Testing Own

04/07/23 Venkata Krishna

////////////delete folderFSO.delete folder (“c:\newfolder\siri”)If FSO.folder exists (“c:\newfolder\siri”) then

FSO. Delete folder (“c:\newfolder\siri”)End if

FSO. Create text file (“c:\newfolder\siri\siri”)If FSO. File exist (“c:\newfolder\siri\siri.txt”) thenMsgbox “file exists”End if

//////////////Enter data into text fileSet ref FSO = FSO. Open text file (“c:\newfolder\siri\siri.txt”, forwriting/2.true)Ref FSO.write (“siritech”)Ref FSO.close

Page 81: Automation Testing Own

04/07/23 Venkata Krishna

Automation Object Model:It is used for automating the QTP tool to overcome manual operations for running the scripts.By using this we can perform batch execution by creating QTP application reference

Ex:Set QTP = create object (“quick test application”)

QTP. visible = trueQTP. Open “script path”

Set QTPFile = QTP.testQTPFile.RunQTP.Open “script path”

Set QTPFile = QTP.testQTPFile.Run………..

QTP.quit

Page 82: Automation Testing Own

04/07/23 Venkata Krishna

Recovery Scenarios:It is used for handling exceptions or unexpected errors.We should need to overcome exceptions for doing batch execution comfortably.3 types of issues we may get in real time environment.

QTP script issueMachine dependent pop-upsApplication issues

QTP script issuesIf we want to continue our batch execution by over coming all the script issues then we have to insert statement “on error resume next”

Note: By using above statement script will be failed if at all any issues but cannot interrupt batch execution.

Recovery Scenario:If we want to manage or recover, remaining issues like machine dependent pop-ups, application unexpected pop-ups then we have to provide recovery information for the type of issue.

Page 83: Automation Testing Own

04/07/23 Venkata Krishna

Navigation:

Resources Recovery scenario manager

We have to provide information for creating any type of recovery scenario, those arePop-up windowObject stateTest run errorApplication crash

For creating above any scenario we have to update below 3 sectionsTrigger eventRecoveryPost recovery

Trigger event contains type of exception to manage.Recovery contains type of solution to overcome the exceptionPost recovery contains after recovering from exception, what need to do by QTP

Page 84: Automation Testing Own

04/07/23 Venkata Krishna

Automation Life Cycle:Manula TC’s

Dry Run

Application functionCommon partsEstimation

Automation Plan

Start End Hours

Phase 1 Functions Resuable actionsEnvironments

80

Phase 2 Intermediate

Phase 3 High

Phase 4 Meduim

Phase 5 Low

Page 85: Automation Testing Own

04/07/23 Venkata Krishna

QTP Life Cycle:

1) Develop the basic script2) Enhance script

recovery scenarioregular expressionenvironment variablefunction librariesreusable actionsshared ORtransaction, FSO, etc.,

3) Debugging Script4) Perform Batch Run5) Deliver Client

Page 86: Automation Testing Own

04/07/23 Venkata Krishna

QTP FrameWorkThe process what we are following for automating the manual test cases is called framework.Based on the application functionality, we have to choose corresponding process for automation.

Framework Types:LinearModularData DrivenKeyword DrivenHybrid Framework

Linear Framework:If at all application functionality is entirely different and there is no scope to reuse and modularize your functionalities then we have to follow linear framework.We cannot maintain reusability and modularity. We can use the features:Recovery scenarioRegular expressionFSOData tableEnvironment variables, etc.,

Page 87: Automation Testing Own

04/07/23 Venkata Krishna

Ex: linear 100 TC’s…………. Sequential………….. Stmts Different …………………….…………………….. No modularity, reusability

Modular Framework:If at all application functionality is having common functionalities which are required in all the test cases then we have to follow modular framework.We will get advantages reusability and modularity because here we are having chance to reuse, some part of navigations, it means we are able to modularize our script.

RA’s 100 TC’sfunctionsshared OR 20 – 30 functionsEV’s 10 RA’s

Page 88: Automation Testing Own

04/07/23 Venkata Krishna

Data Driven:If at all application is having functionalities depend on the test data and data need to drive our script execution then we have to use data driven framework.Along with this process we can use components functions, reusable actions, shared OR.

functions 100 TC’sRA’s 80 TC’s commonEV’s data tableshared OR

Keyword Framework:If at all application is having functionality mostly common and we need to check application functionality by doing small updates in our application, then we have to use keyword driven framework.For all the common functionalities we are maintaining keywords in our library and update keywords and their required objects details in data table.By using above keyword and data table we are fetching each record and performing the keyword call by using datatable arguments.From where we are calling keywords and fetching keywords, we can say it as a driver script.

Page 89: Automation Testing Own

04/07/23 Venkata Krishna

Function login----------------End function

Function ………….Select case“winedit”……………..…………..“winbutton”------------------------“windropdown”---------------------------

End function

Deliver

Call “ “Datatable.value (“keyword”)“-------------”“-------------”“-------------”“-------------”“-------------”

Keyword Micpass Object Value

Login

Click

Set

Data table Test Data

Page 90: Automation Testing Own

04/07/23 Venkata Krishna

Hybrid Framework:Combination of any of 2 frameworks is called hybrid framework.In real time we should required to work with atleast 2 frameworks such as modular and data driven.

Page 91: Automation Testing Own

Web Table:1. rows2. columns3. data of each cell4. exist

Msgbox Browser (“mercury quality center”). Page (“mercury quality center”). Webtable (“quality center”). Getroproperty (“rows”)

Msgbox Browser (“mercury quality center”). Page (“mercury quality center”). Webtable (“quality center”). Getroproperty (“cols”)

Msgbox Browser (“mercury quality center”). Page (“mercury quality center”). Webtable (“quality center”). Getcelldata (3, 1)

Msgbox Browser (“mercury quality center”). Page (“mercury quality center”). Webtable (“quality center”). Getcelldata (1,1)

Msgbox Browser (“mercury quality center”). Page (“mercury quality center”). Webtable (“quality center”). Rowcount

04/07/23 Venkata Krishna