Qtp 9

50
Q.T.P. M A T E R I A L Q.T.P_9 .0 Created by: s.v.s.ramakrishna 1

Transcript of Qtp 9

Page 1: Qtp 9

Q.T.P. M A T E R I A L

Q.T.P_9.0

Created by: s.v.s.ramakrishna 1

Page 2: Qtp 9

Q.T.P. M A T E R I A L

Q.T.P_9.0Anatomy of QTP_9.0:- Detailed analysis of QTP_9.0 structure is called anatomy.

1. Title bar:- It displays test name.2. Menu bar:- It contains quick test command options.3. Tool bar:- It contains short cut icon buttons for frequently used command options. There are following tool bars. View Tool Bars:- a. Standard b. Automation c. Debug d. Edit e. Insert f. Tools g. View h. Actions

4. Test Pane:- It is an IDE(integrated development environment), which is used to develop the test script.

There are two views: 1. Expert View 2. Keyword View.Expert View:- It can be used by the test engineers who has VB script programming knowledge.

Created by: s.v.s.ramakrishna 2

Page 3: Qtp 9

Q.T.P. M A T E R I A LKeyword View:- It can be used by the Test Engineer who doesn’t have VB script programming knowledge. It containing mainly 4 columns:

Item:- It is used to select application object.

Operation:- It is used to select operation which has to be perform on object.

Value:- It is used to select input value to the object.

Documentation:- Once we select item, operation, value columns then quick test generates the corresponding manual statement in English language.

5. Data Table:- It is used to store the test data. (input data to the application)

6. Active Screen:- When the tool is in recording if we perform operations on application then Q.T.P captures snapshots of application and all this snapshots are displayed in active screen, with this snapshot we can enhance the script.

7. Debug Viewer:- It is used to debug the test script.

8. Status Bar:- It displays status of QTP like, Ready, Running, Recording etc.,

Created by: s.v.s.ramakrishna 3

Page 4: Qtp 9

Q.T.P. M A T E R I A LADD-IN MANAGER

Add-in:- It is a plug in program which provides compatibility between QTP and application.

There are two types of Add-in’s:- 1. Build in 2. External

Build in:- When we buy the license of QTP mercury interactive provides some default add ins to test the corresponding applications these add ins are called Built in Add ins.

Ex:- ActiveX Visual Basic Web

External:- When you want to test the applications like Java, .net etc., we have to buy the corresponding add ins explicitly. These add ins are called external add ins.

Ex:- Java, .net, siebel, people soft, oracle abs etc.,

Add-in manager is open when we launch QTP. It displays the list of available add- ins with license style and time remaining. We can modify the existing add in license with new license by clicking on “modify add in license button”.

When we are testing the application by developing test script by executing test script, we have to select the application corresponding add-ins by deselecting remaining add-ins in add in manager.

RECORDING MODES

QTP provides the feature called recording and play back. When test engineer performs actions on application QTP records each action and generates the corresponding VB script statements on test pane. When we execute these script statements same actions will be repeated by QTP on application.

There are three types of recording modes:-

Created by: s.v.s.ramakrishna 4

Page 5: Qtp 9

Q.T.P. M A T E R I A L

1. Normal Recording Mode 2. Analog Recording Mode 3. Low Level Recording Mode

1. Normal Recording Mode:- When the tool is in this recording mode it records objects and operations performed on them. It is a default recording mode in QTP.

Ex:- Clicking on button Entering values into text box Selecting ratio buttons etc., operations can be recorded.

Script Example: Dialog (“Login”).Activate Dialog (“Login”).Win Edit (“Agent Name”).Set “Sunny”.

Navigation----Automation----Record.

Analog Recording Mode:- When the tool is in this recording mode it records the continuous movements performed on the application through keyboard or mouse with respect to desktop or application window, and it records the co-ordinates of movements.

Ex:- Drawing Pictures, Signing on application etc., operations can be recorded.

Script Example: Desktop. Run Analog “Track1” Window(“Flight reservation”). Window(“Fax order no.5). Run Analog “Track1”

Created by: s.v.s.ramakrishna 5

Page 6: Qtp 9

Q.T.P. M A T E R I A L

Navigation:-

Start Normal Recording Automation-Analog Recording Record relative to the following window Start Analog Record – Cancel

Select Required Option (if we select second option Add window title with the help of hand icon button.

Click start analog record button Perform operations on application Select Automation-Analog Recording to go back Normal Recording. Finally Stop Recording.

Low Level Recording:- It is used to record operations performed on the objects who’s environment is not supported by QTP.

Ex:- Power Builder Objects.

Navigation:

Select Normal Recording Automation-Low Level Recording

Record & Run Settings:- It is the process of instructing to QTP on which application it has to record and run the script.

There are two options:

1. Record & run test on any opened application2. Record & run only on the specified application

If we select 1st option Quick Test records the script on any application which is opened by test engineer. If we select 2nd option by specifying application details, Quick Test

Created by: s.v.s.ramakrishna 6

Page 7: Qtp 9

Q.T.P. M A T E R I A Lrecords only on the specified application and it is opened by QTP when we start recording or running the script.

Navigation:

Automation-Record & Run Settings Select Required Option (if we select 2nd option specify application details by

clicking on + icon button.

OBJECT REPOSITORY

Object Repository:- It is a storage place in which objects physical description is stored, with this physical description QTP can identify objects in the process of script execution. There are two types of object in repository:

1. Local Objects2. Global Objects (or) Shared Objects

Objects can be added to repository in two ways:

1. Through Recording2. Pre – Learning

1. Through Recording:- When the tool is in recording mode on which objects we perform operations only those objects are added to repository.

Note:- Through recording objects are added to repository as local objects.

2. Pre – Learning:- Before recording or after recording we can add objects to repository one by one or all at once available in that window.

Created by: s.v.s.ramakrishna 7

Page 8: Qtp 9

Q.T.P. M A T E R I A LNavigation:

Resources-Object Repository Object Menu-Add Objects to Local Click on Object Select Object in Object Selection Dialog Click OK

If the selected object is parent object then the following objects are displayed in a dialog.

Add Object to Repository Only the Selected Object Selected Object and its descendents of type Select the Required Option Click OK

Creating Shared Repository File by Adding Global Objects:- Any object which is used in many actions or test is called global objects. For all these type of global objects which are available in the application will create one are more shared repository files by saving them in a common area. Once we create the shared repository file with object repository manager we have to associated them with the required actions or test using the feature called associate.

Navigation:

Creating Shared Repository File Resources – Object Repository Manager Object Menu – Add objects Click on the Object Select the Object in Object Selection Click OK

To Save the File:-

Created by: s.v.s.ramakrishna 8

Page 9: Qtp 9

Q.T.P. M A T E R I A L File – Save Enter file name by selecting the location Click on Save Button

Note:- Extension of shared repository file is .tsr(Test Shared Repository)

Associating shared repository with the test’s or actions:-

Navigation:

Resources – Associate Repository Click on Add Repository Icon Button Select Repository File Click – Open Select Required Action in Available Actions Section Click on “>” Button (Click on “>>” Button to add All Actions) After Adding Actions to Associated Actions Section-Click on Ok.

Note:- In the process of testing the application in organization we can use the local objects or only shared objects or both.

Deleting object from repository:-

Select Object in Repository Right Click Delete Click on “Yes” Button

Modifying Physical Description:-

Select Object Select Property Value by Clicking on it Enter New Value Press “Enter” Button

Logical Name:- It is a pet name for objects which add as an interface between test pane and repository to get physical description from repository.

Created by: s.v.s.ramakrishna 9

Page 10: Qtp 9

Q.T.P. M A T E R I A L

Modify Object Logical Name:-

Select Object in Repository Right Click

Rename Enter New Name Press “Enter” Button

OBJECT IDENTIFICATION & SMART IDENTIFICATION

In the process of testing the application by performing operation on objects. Initially QTP has to identify objects uniquely. So we have to provide unique description in the repository in learning process. There are two levels to provide unique description and to identify objects uniquely.

1. Learning Process:- In the process of learning object physical description QTP use the difficult property settings to create unique description. We can configure this settings when QTP is not able to identify objects. This settings are available in object identification window.

Navigation: Tools---Object Identification

There are mainly five sections Environment

Created by: s.v.s.ramakrishna 10

Page 11: Qtp 9

Q.T.P. M A T E R I A L Test Object Classes Mandatory & Assistive Properties Ordinal Identifier Smart Identification

1. Environment:- It displays list of application environment names. This environments are available based on add-ins manager. Here we select the current application environment.

2. Test Object Classes:- It displays list of object classes for selected application environment. Here we select any one object class to configure the properties.

3. Mandatory, Assistive Properties:- This sections displays one or more properties, we can add or remove properties for this section, the property which is selected in one section can not be selected in another section.

When QTP learning object description to the repository initially it consider mandatory properties, if this mandatory properties are not enough to create unique description then QTP used assistive properties one by one.

4. Ordinal Identifier:- It contains three properties and these properties are not object physical properties. So Quick Test Assigns its own values based on the specified the criteria for the properties.

The three properties are:

Location Index Creation time(only for web browser object)

1. Location:- When QTP is assigning this property to the repository with the assigns numeric value based on the location of current object on application window.

2. Index:- For this property QTP assign unique numeric value based on source code sequence.

3. Creation Time:- It is available only for web browser objects, for this property QTP assigns unique numeric value based on creation time of browser object in repository.

If QTP is not able to create unique description using mandatory, assistive properties then it used ordinal identifier property. For this property QTP assigning its own value, so it can create unique description for current object definitely.

5. Enable Smart Identification:- It is a mechanism provided in QTP which enables QTP to identify dynamic object though their values are modify frequently.

If we select this option it will be available for identification process in repository. To configure smart identification property click on configure button.

There are two sections: Base filter property

Created by: s.v.s.ramakrishna 11

Page 12: Qtp 9

Q.T.P. M A T E R I A L Optional filter property

We can select one or more properties in this section using Add/Remove Button.

Identification Process:- In the process of script execution initially QTP use physical description (mandatory, assistive) to identify object.

If it is not able to identify(Reason 1. Physical description matched with more than one object. Reason 2. Physical description not matched with any object.)object QTP checks the availability of smart identification for current object. If it is there then QTP use smart identification mechanism to identify the object. When QTP using smart identification it ignored physical description, it will use the base filter, optional filter properties. If QTP is not able to identify object using smart identification then it will use ordinal identifier property(if it is there) this time QTP consider physical description also.

Note1:- If smart identification is not available then QTP use ordinal identifier property. If it is also not available then it returns “identification error”.

Note2:- Smart Identification can identify object when one physical description matched with more then one object, physical description not matched with any object.

Note3:- Ordinal identifier can identify objects when physical description matched with more than one object.

Ex:- “OK” Button

Base Filter Properties Optional Filter Properties

Nativeclass: Button Enabled : True Height : 23

Width : 65 Text : OK X : 25

Y : 30 Windowid: 1

Step 1: Ok, Cancel, Help (BF-Native Class)

Created by: s.v.s.ramakrishna 12

Page 13: Qtp 9

Q.T.P. M A T E R I A LStep 2: Ok, Cancel, Help (OF-Enabled)Step 3: Ok, Cancel (OF-Height)Step 4: Skipped (Width)Step 5: OK (OF- Text)

Note:- If base filter properties are not matched with any object then quick test returns “identification error”.

Object Spy:- It is the feature provided in Quick Test which is used to view application object properties values right day, and the methods supported by object.

Q.T.P Testing Process Levels/Phases

Manual1. Test Creation Generate Basic Script

Recording Insert Verificational Script

Debugging2. Test Execution Verification

3. Result Analysis & Reporting

1. Test Creation:- For the given task we have to create the test script to verify application. We can create the test script in two ways:

1. Recording2. Verification

Recording:- When the tool is in recording we can perform basic operations on application to generate the relevant script statements on test pane by adding object description to the repository. This script is called basic script. If execute this script the same operations are repeated by Q.T.P. It is not verifying the application. In order to verify application we have to insert verificational statements. This time the script is called test script or test.

Manual:- We can generate the test script manually by adding objects to object repository. We can insert the verificational statements like “Checkpoints, Programmatic Statements, Parameterization etc.,

2. Test Execution:- Once we create the test script by inserting verificational statements we can execute it in two ways.

1. Debugging2. Verification

Debugging:- When we are developing the test script there is manual interaction, so there is chance to develop the test script with the syntactical mistakes and logical mistakes. So we have to execute this statements line by line or inserting break points etc., this process is called debugging.

Created by: s.v.s.ramakrishna 13

Page 14: Qtp 9

Q.T.P. M A T E R I A LVerification:- Once we debug the test script the error free test is prepared. So we can execute it on the application to verify by comparing expected and actual values.

3. Result Analysis & Reporting:- Once the test script is executed in verificational mode Q.T.P generates the results for every statement execution in the result window. We can see pass, fail statements with detailed description. The failed cases are treated as defects and these can be reported to the Quality Center(test management tool) using bug tracking tool provided by Quality Center.

VB Script Object Statements Hierarchy

Syntax:-Parent Obj.Class(Parent Name).Child.Obj.Class(Obj.Name).Operation[input value]Ex:- Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "10"

Web & Client Server Methods:-

1. Activate2. Click3. Set4. Crypt.Encrypt5. SetSecure6. Select7. Capture Bitmap8. GetRoProperty9. GetToProperty10. Reporter.ReportEvent

Activate:- It is used to Activate Dialog, Window and Browser.

Syntax:- Object.ActivateEx:- Dialog(“Login”).Activate

Click:- It is used to click on object.

Syntax:- Object.Click[x,y]Ex:- Dialog(“Login”).Click 57,138 Dialog(“Login”).WinButton(“OK”).Click

Set:- For Text Box:- It is used to enter a value to edit box

Syntax:- Object.Set “Value”Ex:- Dialog(“Login”).WinEdit(“Agent name:”).Set “shravanthi”

For Radio Button:- We can use set method to select ratio button

Syntax:- Object.SetEx:- Window(“Flight Reservation”).WinRadioButton(“First”).Set

For Check Box:- We can use set method to select check box

Syntax:- Object.SetEx:- Window(“Flight Reservation”).Dialog(“Open Order”).WinCheckBox(“Order

Created by: s.v.s.ramakrishna 14

Page 15: Qtp 9

Q.T.P. M A T E R I A L No”).Set “ON” or “OFF”

Crypt.Encrypt:- It is used to convert normal string into encrypted string.

Syntax:- Object.Set crypt.Encrypt a=Crypt.Encrypt(“Krishna”) msgbox a

SetSecure:- It is used to enter encrypted string into password edit box.

Syntax:- Object.SetSecure encrypted stringEx:- Dialog((Login”).WinEdit(“Password”).SetSecure Crypt.Encrypt(“mercury”)

Select:- It is used to select an item in combo box

Syntax:- Object.Select “Item”Ex:- Window(“FlightReservation”).WinComboBox(“Fly From”).Select “Paris”

Capture Bitmap:- It is used to capture snapshot of screen and store it in .bmp or .png formats

Syntax:- Obj.Capture Bitmap(File Path)Ex:- Dialog(“Login”), Capture Bitmap “e:\\krishna\\f1.bmp

Test Object:- While execution an object which is present in repository is called test object.

RunTime Object:- While execution an object which is present on application is called runtime object.

GetRoProperty:- It is used to get value from application object.

Syntax:- Object.GetRoProperty(“Property Name”)Ex:- a=VbWindow(“Form1”).VbEdit(“txtInterest”).GetRoProperty(“Text”)

GetToProperty:- It is used to get repository object property value.

Syntax:- Obj.GetToProperty(“Property Name”)Ex:- a=Dialog(“Login”).WinButton(“OK”).GetToProperty(“Width”) msgbox a

Report.Reporet Event:- It is used to report message to the result window as pass or failed or done or warning.

Syntax:- Reporter.ReportEvent Event Step, “Event Status”, “Step name, Test Message”

Events:- micpass

micfail

micdone

micwarning

MIC:- Mercury Integer

Example 1:Created by: s.v.s.ramakrishna 15

Page 16: Qtp 9

Q.T.P. M A T E R I A L

Dim ev,av

ev=30av=20

If ev=av Reporter.ReportEvent micpass, “comparison”, “Exp and Act values are same, pass”Else Reporter.ReportEvent micfail, “comparison”, Exp and Act values are same, fail”End if

Example 2:

Dim p,t,r,ev,av

VbWindow(“Form1”).Activate VbWindow(“Form1”).VbEdit(“Principle”).Set “1000” VbWindow(“Form1”).VbEdit(“Time in Years”).Set “5” VbWindow(“Form1”).VbEdit(“Rate”).Set “3” VbWindow(“Form1”).VbButton(“Interest”).Click

av= VbWindow(“Form1”).VbEdit(“Interest”).GetRoProperty(“Text”) ev=(p*t*r)/100

If cdbl(ev)=cdbl(av) then

Reporter.reportEvent micpass, “Interest Verification”, “interest properly calculated, pass”

Else

Reporter.reportEvent micfail, “Interest Verification”, “interest not properly calculated , fail”

End if

Interview Questions:-

1. How do you report message to the result window?

2. How do you get application displayed values dynamically?

3. What is QTP testing automation process?

4. How many phases are there in Q.T.P testing process?

5. What is the purpose of documentation column in keyword view?

6. How do you configure keyword view?

CHECK POINTS

Created by: s.v.s.ramakrishna 16

Page 17: Qtp 9

Q.T.P. M A T E R I A LIt is verification point/validation point/test point which is used to compare the current values (V2=Actual Values) of an application and application with expected values (V1=Expected Values) and displays result in result window as pass/fail.

OPERATIONAL OVERVIEW OF CHECK POINTS

I. Pre-Execution Phase:-

1. It capture expected value.2. Generates script statement with expected values.

II. While Execution Phase:-

1. Reads actual value.2. Compares Expected &Actual Values.3. Display result in result window as pass/fail.

Note:- Check point can we use once the version or build is stable.

Application may have GUI objects, Bitmap or Test strings, Database, XML files etc., so to verify all these features Q.T.P provides the following different types of check points.

Types of check points:-

1. Standard Checkpoint2. Bitmap Checkpoint3. Text Checkpoint4. Database Checkpoint5. Image Checkpoint6. Webtable Checkpoint7. Accessibility Checkpoint8. XML Checkpoint

Checkpoint Syntax:-

Object. Check Checkpoint(“Checkpoint Name”)Check:- it is used to compare expected and actual values.Checkpoint(“Checkpoint Name”):- It contains expected properties and values of an object.

1. Standard Checkpoint:- It is used to compare GUI standard objects properties and values.

Navigation:

Select Recording---Insert Checkpoint---Standard Checkpoint---Click on Application object---Select object in object selection dialog---Click “OK”---Select required property in Checkpoint properties dialog---Click “OK”

Syntax:- VbWindow(“Form1”).VbButton(“ClickMe”).Check Checkpoint(“ClickMe”)

Note:- Checkpoint will returns Boolean value (True or False)

Ex:- A= VbWindow(“Form1”).VbButton(“ClickMe”).Check (Checkpoint(“ClickMe”))If a=False thenVbWindow(“Form1”).VbButton(“ClickMe”).Capture Bitmap d:\krishna\srk.bmpEnd if

Created by: s.v.s.ramakrishna 17

Page 18: Qtp 9

Q.T.P. M A T E R I A LIn above example if Checkpoint failed it returns false. If it is passed then it returns true. If the value is false then it capture snapshot of object and it will be stored in the specified location.

Navigation:- To insert Checkpoint through active screen.Step1: Place cursor on object statement for which we want to insert CheckpointStep2: Place cursor on a action object---right clickStep3: Select insert standard CheckpointStep4: Select object in hierarchy---Click okStep5: Select required propertyStep6: Select the option either before current step or after current stepStep7: Click ok

2. Bitmap Checkpoint:- It is used to capture bitmaps of application available on objects or window(Screen Area)

Object Checkpoint:-

A=VbWindow(“Form”).VbButton(“BMP”).Check (Checkpoint(“BMPCHK”))

Navigation:-

Created by: s.v.s.ramakrishna 18

Page 19: Qtp 9

Q.T.P. M A T E R I A L

Select Recording--BitmapCheckpoint--Click on the bitmap--select object--save--ok--click ok

Screen Area Bitmap:-

Window(“Paint”).WinObject(“Afx:1000000,8”).Check Checkpoint(“Afx:1000000,8”)

Navigation:-

Select Recording--Insert--Checkpoint--Bitmap Checkpoint—Click on Bitmap---Select Object—Click OK—Click on Select Area Bitmap—Select the required screen Area Bitmap with Mouse Pointer—Right Click—Select Save Only Selected Area CheckBox(if it is required)—Click OK.

Text Check Point:- It is used to compare text of an application.

3. Database Check Point:- It is used to verify database table values.

Ex:- DBtable(“Conn_string”).Check Checkpoint(“DBtable)

Note:- When we are inserting database checkpoint, we have to provide database connection string and sql query to capture expected data or actual data.Navigation:-Insert---Checkpoint---Database Checkpoint---Select specify SQL statement manually---Click Next---Click on Create Button---Click New---Select Driver(Ex:-Microsoft Access Driver.mdb)---Click next---Enter DSN Name---Click Next---Click Finish---Click Select---Select Database Name---Click OK---Click OK---Enter SQL Statement(select * from table1)---click finish---Click OK.

Web Application Checkpoints:-Image Checkpoint:- It is used to verify where image object properties values.

Ex:- Image CheckpointBrowser(“MQC”).Page(“MQC Page”).Image(“App name”).Check Checkpoint(“Checkpoint)

Navigation:-Select Recording---Insert---Checkpoint---Standard Checkpoint---Click on image object---Select image object in object hierarchy---Click OK---Select Required Properties---Click OK.

Page Checkpoint:- It is used to verify the web page load time, no of images, no of links, properties.

Ex:- Browser(“MQC”).Page(“MQC Page”).Check Checkpoint(“QC page”)

Navigation:-Select Recording---Insert---Checkpoint---Standard Checkpoint---Click on Page---Select Page Object in Object Hierarchy---Click OK---Select the Properties---Click OK.

Web Table Checkpoint:- It is used to verify web tables, cell values.

Ex:- Browser(“MQC”).Page(“MQC Page”).Webtable (Quality Center”).Check Checkpoint(“Quality Center”)

Navigation:-Start Recording---Insert---Standard Checkpoint---Click on Table---Select WebTable Object Hierarchy---Click OK---Select the Required Cells---Click OK.

Created by: s.v.s.ramakrishna 19

Page 20: Qtp 9

Q.T.P. M A T E R I A LAccessibility Checkpoint:- It is used to verify web standards provided by world wide web ------------------------( ) The standards are:

1. Active Check2. All Property Check3. Applet Check4. Frame Tides Check5. Multimedia Links Check6. Server Side Image Check7. Table Check

Ex:- Browser(“MQC”).Page(“MQC Page”).Check Checkpoint(“Page1”)

Navigation:-Start Recording---Insert---Checkpoint---Accessibility Checkpoint---Click on Page---Click OK---Click OK.

Note:- To configure accessibility check point used the following navigation.

Tools--- Options---Web Tab---Click on Advanced Button---Click the Required Options in Accessibility Checkpoint Section---Click OK---Click OK.

XML Checkpoint:- It is used to verify XML file attributes and values.

Ex:- XMLfile(“file name”).Check Checkpoint(“file name”)

Navigation:-Insert---Checkpoint---XML Checkpoint---Click on Browse Button---Select File---Click Open---Click OK---Select the required attributes or values to verify---Click OK.

OPENING APPLICATION USING SCRIPT STATEMENT AT RUN TIME

Invoke Application:- It is used to open client server application (.exe file).

Syntax:- Invokeapplication <filepath>Ex1:- Invokeapplication“c:\programfiles\mercuryinteractive\quicktestprofessional\samples\flight\app\flight4a.exe”

Ex2:- Inokeapplication “c:\Documents and settings\administrator\desktop\v1\my_cal.exe”

2. Systemutil.run:- It is used to open any file in the corresponding application, so it is used to open client server as well as web application.

Syntax:- Systemutil.run <file>Ex:- Systemutil.run “C:\programfiles\mercuryinteractive\quicktestprofessional\flight4a.exe”Ex:- Systemutil.run “Http://sunnysoft\\qcbin\opening textfile”

DATA DRIVEN TESTING & PARAMETERIZATION

Parameterization:- It is the process for replacing constant/fixed values in the text script with parameters in order to send input values to the application dynamically with automation script.

(or)Replacing the constant values in the test script with parameters is called parameterization.

Note:- There are Five types of Parameters in Q.T.P

Created by: s.v.s.ramakrishna 20

Page 21: Qtp 9

Q.T.P. M A T E R I A L1. Data Table2. Environment3. Random Number4. Action5. Test

Data Driven Testing:- It is the process of testing the application with multiple data (Positive, Negative) by parameterizing the test script.

Areas in which we can use the parameters in test script:-

1. In place of fixed/constant values on test pane.2. In place of object properties values in object description.3. In place of Expected values in Checkpoint properties window.

Test Data Sources:- There are three sources to store test data(Input data to application)

1. Excel File2. Data Base3. Flat File(Notepad)

Note1:- Before developing the test script test engineer prepares test data in any one data source(mostly excel file).

Note2:- Test data may be prepare by test engineer or given by the developer or given by the customer. (mostly test engineers prepares test data).

Develop the test script to test shravanthi_calc application by parameterizing test script.

Steps to develop data driven test

Step1:- Record the basic script and insert verificational statements(Ex:-Checkpoints)Step2:- Import the data to the design table from external data source(Excel, Database, Flat file)Step3:- Replace the constant values with data table parameters.

1. Navigation to parameterize constant values on test pane

Created by: s.v.s.ramakrishna 21

Page 22: Qtp 9

Q.T.P. M A T E R I A LKeyword View---Select value in value column---Click on configure the value icon button<#>---Select parameter option---Select location in data table(Ex:-Global Sheet)---Select column name---click ok

2. Navigation to parameterize object description(property value)

Place cursor on object logical name---right click---select object properties option---select property value(Text)---click on configure the value icon button---select parameter---select location in data table---select column name(parameter)(Ex:-btn)---click ok---click ok

3. Navigation to parameterize checkpoint expected values

Place cursor on checkpoint---right click checkpoint properties---select parameter option---click on parameter options icon button---select location in data table---select column name(Ex:-Exp)---click ok---click ok

4. Navigation to import the data to the design time data table.

Importing from excel file:-

Select sheet in data table (Global)---right click sheet---import---from file---click ok---select file---click open---click select sheet---click ok.

5. Navigation to import complete file data:

Right click on data table---file arrow mark---Import from file---ok---select file---lick open.

Importing from Database table:-

Select sheet(Global)---right click---sheet---import---from database---select specify SQL statement manually---click next---create connection screen by clicking on create button---enter SQL query (select * from table1)---click finish

Importing from Flat file:-

Select sheet(global)---right click---sheet---import---from file---click ok---select tabbed text in files type combo box---select notepad file---click open

Note:- In notepad file when we are preparing the test data we must maintain tab space between the data values & columns

Exercise1:-

VbWindow(“Form1”).ActivateVbWindow(“Form1”).VbEdit(“Text1”).Set datatable(“V1”,dtgglobalsheet)VbWindow(“Form1”).VbEdit(“Text2”).Set datatable(“V2”,dtgglobalsheet)VbWindow(“Form1”).VbButton(“Add”).ClickVbWindow(“Form1”).VbEdit(“Text3”).Check Checkpoint (“Text”)

Note:- When we have the data in global sheet the test will be iterated based on the following settings.

Navigation:-

File---Settings---RunTab

Here the default option is run on all rows.

Created by: s.v.s.ramakrishna 22

Page 23: Qtp 9

Q.T.P. M A T E R I A L

For loop statement

The following program can be use when the data available in local sheets.(action1,action2 etc.,)

For i=1 to 7

VbWindow(“Form1”).ActivateVbWindow(“Form1”).VbEdit(“Text1”).Set Datatable(“V1”,DtGlobalSheet)VbWindow(“Form1”).VbEdit(“Text2”).Set datatable(“V2”,dtgglobalsheet)VbWindow(“Form1”).VbButton(“Add”).ClickVbWindow(“Form1”).VbEdit(“Text3”).Check Checkpoint (“Text”)Datatable.Set Next Row

Next

Navigation for data driven wizard:

Go to tools---Data driver---select value---click parameterize button---select step/step parameterization method---click next---click on parameter options icon button---select parameter type(data table or environment or random number)---select location in data table---enter column name(if columns are not available in data table)---click ok---next---finish.

Developing programs to test the application with multiple data by getting the data from data sources at run time.(while execution)

Excel File:-

Data Table:- It is a Microsoft third party excel sheet. Integrated with quick test, which is used to store application input data.

There are two types of data tables:-

1. Design time data table.2. Run time data table.

1. Design time data table:- It is a type of data table which is used by test engineer to parameterize the test script in design time.

2. Run time data table:- While execution the data table which is used by Q.T.P is called run time data table. When we start execution Q.T.P takes a copy from design time data table and it will use the copied table. It is called run time data table. Once the execution is completed run time data table is exported to result window.

DATA TABLE METHODS

1. Add sheet data table2. Delete sheet data table3. Export data table4. Export sheet data tables5. Import sheet data table6. Get Row Count data table7. Get sheet data table8. Set current row data table9. Set next row data table

Created by: s.v.s.ramakrishna 23

Page 24: Qtp 9

Q.T.P. M A T E R I A LAdd sheet:- It is used to add a new sheet at all run time table.

Syntax:- Datatable.addsheet <Sheet Name> Wait(n)Ex:- Datatable.addsheet “mysheet”

Wait(5)

Delete sheet:- It is used to delete an existing sheet.

Syntax:- Datatable.delete <Sheet Name> Wait(n)

Ex:- Deletetable.delete sheet “action” Wait(5)

Export:- It is used to export run time data table through external file

Syntax:- Datatable.Export <file path>Ex:- Datatable.Export “f:\f1.xls”

Export sheet:- It is used to export run time data table sheet

Syntax:- Datatable.Export <file path>; sheet name/IDEx:- Datatable.Export “f:\\Testdata\\f1.xls; “Action”

Import:- It is used to import external data file with the run time data table.

Syntax:- Datatable.Import <file path>Ex:- Datatable.Import “f:\testdata\f1.xls”

Import sheet:- It is used to import an external sheet data file with run time data table sheet.

Syntax:- Datatable.importsheet <filepath>, source sheet/id or data sheet/id.Ex:- Datatable.importsheet “f:\testdata\f1.xls”, “sheet”, “action”.

Get Row Count:- Get row count of run time data table sheet by default it gets row count from global sheet.

Syntax:- Datatable.Getrowcount Msgbox r count

Get sheet:- It returns a specified sheet with run time data base as active sheet.

Syntax:- Datatable.Getsheet (sheet name/id)Ex:- rcount=datatable.getsheet(“Action1”).Get row count msgbox rcount

Set row count:- It is used to set a specified row is active row.

Syntax:- Datatable.Setcurrent row <row no>Ex:- Datatable.Setcurrent row 4

Set next row:- It sets next row be the current row as active row.

Syntax:- Datatable.Setnextrow <row no>Ex:- Datatable.Setnextrow 5

Set previous row:- It sets previous row be the row of active row.Syntax:- Datatable.Setprevrow <rowno>Ex:- Datatable.Setprevrow 5

Created by: s.v.s.ramakrishna 24

Page 25: Qtp 9

Q.T.P. M A T E R I A L*Add parameter:- It is used to add a new column to the run time data table sheet.

Syntax:-

*It is used to be set the retrieve value if its file default properly with the data table.

Syntax:- Datatable.Value(Column Value, Sheet Name)Ex1:- Datatable.Value(“Ename”,Dataglobalsheet)Ex2:- Datatable.Value(“ename”,dataglobalsheet

DATABASE CONNECTONS

1. For Ms.AccessDim con,rsSet con=createobject(“ADODB.connection”)Set rs=createobjeft(“ADODB.recordset”)con.provider=”microsoft.jet.oledb.4.0”con.open “Database Path”rs.Open “Query”, conrs.fields(“Fieldname”)rs.fields(“Fieldname”)rs.fields(“Fieldname”)rs.fields(“Fieldname”)

Exercise: Case StudyTest the following interest calculation application by getting the data from data base datasource.

Dim con,rsSet con=createobject(“ADODB.connection”)Set rs=createobjeft(“ADODB.recordset”)Con.provider=”microsoft.jet.oledb.4.0”Con.open “e:\\testdata\\db1.mdb”Rs.open “Select * from Table1”, conWhile not rs.EOFVbWindow(“Srn_Int_Cal”).ActivateVbWindow(“Srn_Int_Cal”).VbEdit(TxtPrinciple”).Set rs.fields(“Principle”)VbWindow(“Srn_Int_Cal”).VbEdit(TxtTime”).Set rs.fields(“Time”)VbWindow(“Srn_Int_Cal”).VbEdit(TxtRate”).Set rs.fields(“Rate”)VbWindow(“Srn_Int_Cal”).VbButton(“Interest”).Clickav= VbWindow(“Form1”).VbEdit(“InterestAmount”).GetRoProperty(“Text”)

Created by: s.v.s.ramakrishna 25

Page 26: Qtp 9

Q.T.P. M A T E R I A Lev=rs.fields(“Exp”)If cdbl(ev)=cdbl(av) thenReporter.ReportEvent micpass, “Interest Verification”, “Interest properly calculated”ElseReporter.ReportEvent micfail, “Interest Verification”, “Interest not properly calculated”End ifrs.movenextWend

2. For SQL server driver

Con.provider=”driver=sqloledb.1;server=servername;uid=userid;pwd=password;database=databasename;

Ex:-Con.provider=”driver=sqloledb.1;server=localhost;uid=sa;pwd=;database=master”

3. For Oracle Server

Con.provider=”driver=oraoledb.1;server=localhost;uid=scott;pwd=tiger;database=emp”

Flat file database source:-

File system object:- It is Vb script built in object which is used work with computer files. It support the following methods and properties.

1. Create folder2. Copy folder3. Delete folder4. Create Text file5. Copy Text file6. Delete Text file7. Open Text file8. Write Line9. Read Line10. Skip Line11. Close

The above methods and properties can be used by creating user defined file system objects.

Syntax:-

Dim fsoSet fso=createobject(“scripting.filesystemobject”)

Delete folder:- It is used to delete an existing folder

Syntax:-

Dim fsoSet fso=createobject(“scripting.filesystemobject”)Fso.createfolder “e:\testdata\f1”Fso.deletefile “e:\textdata\f1.txt”

Create Text file:- It is used to create empty text file

Syntax:- fso.createtextfile “e:\testdata\f1.txt”

Created by: s.v.s.ramakrishna 26

Page 27: Qtp 9

Q.T.P. M A T E R I A LCopy File:- It is used to copy by one location to another location

Syntax:- fso.copyfile “e:\testdata\f1.txt”, “f:\krishna\”

Open Text file:- It is used to open text file in that specified mode and returns file stream.

Syntax:- Set f=fso.openfile(“file path”, open mode, return mode)

Open mode: it has three modes:-

1. For Reading2. For Writing9. For Appending

Return mode:- It has two modes1. True2. False

Dim fso, fSet fso=createobject(“scripting.filesystemobject”)Set f=fso.opentextfile(“f:\\sunny\\f1.txt”,2,true)

Write line:- It is used to write a new line in opened file.

Syntax:- f.writeline “sunnysoft”

Read Line:- It is used to read a line from opened file.

Syntax:- ln=f.readline Msgbox ln

Skip Line:- it is used to skip current line

Syntax:- f.skipline Ln=f.readline

Close:- It is used to close an opened file

Syntax:- f.close

CONSTANT FUNCTION

Constant function:- It is Vb script function used to constant a line based on the separator and returns the values to array variable.

Syntax:-

arr=split(string, “separator”, returns mode, format)

Returns modes -1 and 1. -1 returns substring, and 1 returns as one complete string

Ex:- The following program is used test interest calculation application with multiple data if the data available in flat file.

Dim fso, f, ln, ev, avSet fso=createobject(“scripting.filesystemobject”)Set f=fso.opentextfile(“f:\\sunny\\file1.txt”, 1, false)f.skipline

Created by: s.v.s.ramakrishna 27

Page 28: Qtp 9

Q.T.P. M A T E R I A Lwhile not f.atendofstreamln=f.readlinearr=constant(ln,“#”,-1,1)VbWindow(“Form1”).ActivateVbWindow(“Form1”).VbEdit(TxtPrinciple”).Set arr(0)VbWindow(“Form1”).VbEdit(TxtTime”).Set arr(1)VbWindow(“Form1”).VbEdit(TxtRate”).Set arr(2)VbWindow(“Form1”).VbButton(“Interest”).Click

av=VbWindow(“Form1”).VbEdit(“TxtInterest”).GetRoProperty(“Text”)ev=arr(3)

If cdbl(ev)=cdbl(av) thenReporter.ReportEvent micpass, “Interest Verification”,”Interest properly calculated”

ElseReporter.ReportEvent micfail, “Interest Verification”,”Interest not properly calculated”

End ifWend

Random Number Parameter:-

It is one type of parameter in QTP which is used to get values randomly from specific numeric range and the retrieved values will be send as input to the application.

Syntax:- Window(“Fr”).Dialog(“Openorder”).WinEdit(“Orderno”).Set randomnumber(1,100)

Navigation:-

Keywordview---select value in valuecolumn---click configure value icon button---select parameter(random number, enter numeric range, click ok)

ENVIRONMENT PARAMETERS

In the process of developing the test script any re usable values are there we can store them in environment parameters so that the values will be available globally for one or more tests. In other words environment parameters can be used as global variables for entire project(for all the test scripts.

Environment parameters are two types: 1. Built in 2. User Defined

1. Built In:-These are system defined parameters used to store system generated values.

Ex:- “OS”, “ProviderVer”, “ProductDir”, “TestDir”, “ResultDir” etc.,

2. User Defined:- These parameters are used to store re-usable values like test data path, data base path, user names, password, etc.,

There are two types of user defined parameters: 1. Internal 2. External

Internal:- These parameters will be available only for one test.(all actions in the test)

Navigation to define internal parameters:-

File---Settings---Environment Tab---Select User Defined Type---Click on +Button---Enter Name & Value---Click ok

Created by: s.v.s.ramakrishna 28

Page 29: Qtp 9

Q.T.P. M A T E R I A LExternal:- This parameter values can be used in many tests by loading this parameters from tests.

Defining external parameters:

Open Notepad

Write the parameters&values and save file with .xml extension.

<Environment>

<Variable>

<Name>an</Name> <Value>sunny</Value>

</Variable> <Variable>

<Name>pw</Name> <Value>mercury</Value>

</Variable>

</Environment>

To display parameter value Environment.Value(parametername)

To Load external parameter values

Environment.Load from file <file path>

Ex:- Environment.Load from file “f:\\myenv.xml”

Invokeapplication Environment.Value(“ProductDir”&\\samples\\flight\\app\\flight4u.exeDialog(“Login”).ActivateDialog(“Login”).WinEdit(“Agent name”).Set Environment.value(“an”)Dialog(“Login”).WinEdit(“Password”).Set environment.Value(“pw”)Dialog(“Login”).WinButton(“OK”).Click

VIRTUAL OBJECT CONFIGURATION

In the process of recording the test script when we click on a feature which is having a specific functionality QTP generating the script statement as if we clicked on screen area (window) Because the feature is non real object, so we have to configure these non real objects. In order to differentiate the script statements and to provide some methods to test this type of features.

Navigation:-

Tools---Virtual Objects---New Virtual Object---Click Next---Select Standard Class(Ex:-Button)---Click Next---Click Mark Object---Select Screen Area Carefully---Click Next---Select either entire parent hierarchy or parent only---Click Next---Enter Object Name---Enter Collection Name---Select No---Click Finish.

Created by: s.v.s.ramakrishna 29

Page 30: Qtp 9

Q.T.P. M A T E R I A L*Ex:- Before ConfigurationVbWindow(“frmmain”).VbWindow(frm Virtual Object”) Click 153, 46

* After ConfigurationVbWindow(“frmmain”).VbWindow(“from Virtual Button”)(“Click Me”) Click

Interview Questions:

1. What is virtual object?2. Tell me about environment parameters?3. How do you import data as runtime from excel file?4. How do you write a line in text file?5. Who prepares test data?6. How many data sources are there to store test data?7. What is data driven testing?8. How many type of parameters are there in QTP?9. How do you declare external environment parameters?10. What is the database connection for SQL Server?11. What is the difference between winrunner Gui Spy and QTP Object Spy?

REGULAR EXPRESSIONS

Regular Expression:- It is a search string which is used to match varying test strings. In the application any object label is being modified dynamically (at run time) then Q.T.P can not identify these type of objects or windows. We w have to use regular expression in the repository in place of object label or window title. Here onwards Q.T.P can identify the objects or windows.

Q.T.P provides the following frequently used regular expressions, special characters to implement regular expression string.

. (period):- It matches single character in varying string.* (astrik):- It matches n number of characters in varying string.[x,y] (list):-It matches single character from the list.[x-y] (range):- It matches single character from given range of characters.

Ex:- St.* ---(Start/Stop) Faxorderno [0-9][0-9] ---(Faxorderno.15/Faxorderno.25/etc., Ticket. ---(Ticket1/Ticket2/etc)

Exercise1:-In flight reservation application if we send multiple orders information one by

one for every order, the fax order window title will be modified. Q.T.P can not identify this window in order to identify we have to use regular expression in repository.

Navigation:-Develop the test script to open order’s information using open order window

and to send it using fax order window. (To open multiple orders, order number should be parameterize)

Resources---Object Repository---Select Fax Order Window Logical Name---Select Text Property Value---Click on Configure Value Icon Button---Enter Regular Expression String---Select Regular Expression Option.

Created by: s.v.s.ramakrishna 30

Page 31: Qtp 9

Q.T.P. M A T E R I A L

Click on “No”---Click on “Ok”

Note:- When we are using * we have to use period as prefix to * character. Ex:- .*

Output Values:- It is the feature provided in Q.T.P which is used to capture application displayed output values and store them in data table.

Once the data is stored in data table(runtime) we can use it. Like

1. for comparison purpose2. for sending the data as input to the another screen. If the screens are

integrated screens.

There are 4 types of output values

1. Standard output value2. Text3. Database4. .XML

Standard Output Value:- It is used to capture output values from standard objects.

Ex:- Window(“FR”).ActiveX(“Fdate”).Output Checkpoint(“Flightdate”)

Navigation:-

Select Recording---Output Value---Standard Output Value---Click on Object---Select Object Hierarchy---Click on OK---Select Property(Text)---Click on Modify Button---Select Sheet---Enter Name(Ex:- date)---Click on OK.

Text Output Value:- It is used to capture application displayed test strings and store them in data table.

Database Output Value:- It is used to capture Output Values from Database Table.

.XML Output Value:- It is used to capture XML file attributes value and store them in data table.

Syntax:- Object.Output CheckPoint(“Output Value Name”)

Output:- It is a method to capture values from application and store them in data table. It contains output value properties. (Ex:-Table Column Name, Object Property Name Etc.,)

Created by: s.v.s.ramakrishna 31

Page 32: Qtp 9

Q.T.P. M A T E R I A LInterview Questions:-

1. Tell me about regular expression?2. Can you explain regular expression with an example how you use in your

project?3. What is output value in Q.T.P?4. What are the types of output values?

LIBRARY FILES

Library file:- Set of re-usable functions, procedures and classes defined in .vbs file is called library file.

Local Script Function:- We can define a function on Q.T.P Test pane(within action) or in library file. If we define a function within action that function can be re-used only for the current action. We can not re use that in another action in current test or other tests.

Library Function:- If at all we want to re-use a function in many actions in current test or other tests then it should be define in library file.

Once we define a library file we have to associate it with test settings.

Navigation:-

File---New Function Library---Select Library Tab on Q.T.P Pane---Define one or more functions.

To Save file--File---Save---Enter file name with extension .vbs---Click on Save Button.

Library file1.vbs

Function Div(x,y) Dim z z=x/y Div=z End Function

Function Div(x,y) Dim z z=x/y Div=z End Function

Navigation to Associate a Library File:-File---Settings---Resources---Click on + Button in Library Section---Click on Browse Button---Select File Name---Click on Open---Click on OK.

Set as Default Button:- If we click on this button the associated library files will be available for new tests by default.

Check Syntax Button:- If we click on this button Q.T.P will verify the syntactical mistakes in associated library files.

Created by: s.v.s.ramakrishna 32

Page 33: Qtp 9

Q.T.P. M A T E R I A L

Once we associate the library file we can call functions one or more actions in the tests.

Ex:-

SYNCHORNIZATION It is the process of keeping the tool and application in sink with each other by matching tool & application times in order to complete script execution successfully.(or) It is the process of matching the tool time and application time in order to complete script execution successfully.

Q.T.P provides the following synchronization options:-

1. Object synchronization time out or default time.2. Synchronization point or wait property method.3. Exist method.4. Sync method. (only for web applications)

Default Time:- It is the maximum time out provided by Q.T.P by default for every test in order to execute the individual statements successfully. The default time in Q.T.P is 20 Seconds. We can increase or decrease the default time, but we should not give more time (like 2 min, 5min etc.,) unnecessarily. Because whenever object is not identify operation not able to perform then Q.TP will wait upto default time to raise error. So it is wasting our time.

Navigation to modify default time:-

File---Settings---Run Tab---Object Synchronization Time Out 20 in text box---Click on OK.

Note:- We can increase the default time when default time is not enough for many script statements.

Note2:- If the default time is not enough for one or two statements then we can use wait property or exist method.

Synchronization point or wait property method:- It is a conditional based waiting mechanism using with we an keep the Q.T.P in waiting state until the specified condition satisfy.

Navigation:-

Created by: s.v.s.ramakrishna 33

Page 34: Qtp 9

Q.T.P. M A T E R I A LSelect the area on test pane---Select Recording---Insert---Synchronization Point---Click on Object---Select Object in Object Hierarchy---Click on OK---Select Property Name(ex:-“enabled)---Enter Value(ex:-“True”)---Click on OK.

Window(“FlightReservation”).Winbutton(“DeleteOrder”).WaitProperty”enabled”,True,10000

RECOVERY SCENARIO MANAGER (EXCEPTION HANDLING)

In the process of script execution the test script execution may be interrupted due to the unexpected events (exceptions) occurred on application to runtime execution process successfully we have to handle unexpected events. For this Q.T.P provides feature called recovery scenarios.

Application may cause the following types of unexpected events or exceptions:-

1. PopUp Window2. Object State3. Test Run Error4. Application Crash

PopUp Window:- Window pop’s up on opened application during run session is called popup window.

Object State:- State of an object (object disable, not displayed etc.,) is being changed unexpectedly at run time.

Test Run Error:- A step in the test is not executed successfully then it returns error, it is called test run error(ex:-Item not found, object not identified etc.,)

Application Crash:- An opened application is not responding and it is closed unexpectedly is called application crash.

Steps to define recovery scenario for an exception:-

Step1: Identify an exception which may occur during run session on applicationStep2: Create Recovery Scenario using recovery scenario wizard by specifying trigger event, recovery operations and post recovery test run options.

Trigger Event:- An event which has to be triggered(fired) when exception is occurred.

Recovery operations:- An operation which has to be performed to handle exception.

Post Recovery Test Run Option:- Once exception was handled how Q.T.P should continue the script execution has to be selected.

Step3: Once one are more scenarios are created for one are more exceptions save them in a file called recovery file. The extension of recovery file is .qrs(quick recovery scenario).

Step4: Once recovery file is created we have to associate a file with test settings by selecting recovery activation options.

On every Step On Error Never

On Every Step:- The scenario is activated by default for every step execution.

On Error:- When Q.T.P returns error that scenario is activated.

Created by: s.v.s.ramakrishna 34

Page 35: Qtp 9

Q.T.P. M A T E R I A LNever:- For the complete run session the scenario will be deactivated.

Navigation to create recovery scenario:-Resources---Recovery Scenario Manager---Click on New Scenario Icon Button---Wizard is Open---Click Next---Select Type of Exception(ex:-pop up window)---Click Next---Select Hand Icon---Click on PopUp Window Title to Capture Window Title---Click Next---Select Operation Type(ex:-Keyboard or mouse operation)---Click Next---Select any option to perform operation on application (ex:-Click button with label)---click next---Deselect add another recovery operation (if not required)---Click Next---Select test run option---Repeat current step and continue---Click Next---Enter Scenario Name(ex:-Popup_Login)---Click Next---Click Finish---Click on Save Button in recovery scenario manager to save the created scenarios in recovery file---Click Close.

Navigation to associate the recovery file with test settings:- File---Settings---Recovery Tab---Click on + icon---Click on Browse---Select Recovery file---Click Open---Select Scenario---Click add scenario button---Select Scenario activation option(ex:-on error)---Click Ok.

WITH STATEMENT

With Statement:- It is used to execute series of statements with single object.

Navigation to generate with statement after recording:-Tools---Options---General Tab---Select Automatically Generate “With” Statement after recording check box---Generate “With” Statement for 4 or more objects---Editable---Click OK.

Navigation to Generate “With” Statement Without Recording:Edit---Advanced---Apply “With” to Script---Click OK.

Navigation to Remove With StatementEdit---Advanced---Remove With Statements---Click OK.

Note:- Q.T.P Supports object based programming so we can write down the script formats.

Ex:- Dim lobjSet lobj=Dialog(“Login”)Lobj.ActivateLobj.Winedit(“Agentname:”).Set “Sunny”Lobj.Winedit(“Password:”).Set “Sunny”Lobj.WinButton(“OK”).Click

OPTIONAL STATEMENTS

Optional Statement:- It is used to bypass test object statement when an object is not identified in the statement and continues with next statement.

Syntax:- Optionalstep.Test object statementEx:- Optionalstep.Window(“FlightReservation:”).WinRadioButton(“First”). Set

Created by: s.v.s.ramakrishna 35

Page 36: Qtp 9

Q.T.P. M A T E R I A L

TRANSACTION STATEMENTS

Transaction statements:- The transaction statements are used to measure the time taken by the application to complete specific task(To save the data to database, to update the data etc.,)

The Q.T.P provides two transaction statements To Start and To End transactions.

Services.StartTransaction "Transaction Name"Services.EndTransaction "Transaction Name"

Ex:- Services.StartTransaction "Tr1"Window(“FR”).Winbutton(“DeleteOrder”).ClickWindow(“FR”).Dialog(“FRS”).WinButton(“Yes”).ClickServices.EndTransaction "Tr1"

Navigation to insert start & end transactions:Insert---Start Transaction---End Transaction

UPDATE MODE:- Automation---Update Mode:- It is used to replace existing repository physical description and active screen snap shots with current AUT physical description and snap shots.

RUNNING TEST IN VERIFY MODE:- The test can be executes individually or all at once.Initially we execute the test scripts one by one to verify individual screens once we integrate the screens to generate a module we have to execute all the test scripts in a single run session to test complete module. Q.T.P provides us two ways to execute multiple test scripts in a single run session.

1. Test Batch Runner2. Automation Object Model(AOM)

Test Batch Runner:- It is used to execute multiple test scripts in order to test the module or complete application. Using this tool we can create a batch file by adding number of Q.T.P scripts. Extension of batch file is .mtb. Once we execute the batch file we can see the results using test results viewer.

Navigation to create & run batch file:Start---Programs---Q.T.P---Tools---Test Batch Runner

To Add Tests:- Batch---Add---Select Test---Click Open

To Save Batch File:- File---Save

To Run Batch File:- Batch---Run

Navigation to view the results:Start---Programs---Q.T.P---Tools---Test Result Viewer---File---Open---Click Browse Button---Select the Test---Select Result Name---Click Open

As we use Q.T.P to automate the manual testing process (developing test & executing test) we can use Q.T.P automation object model to automat Q.T.P itself.

Using AOM we can execute number of test scripts in a single run session by configuring them at run time (modifying add in selection, libraries, recovery files, repository files etc.,) using objets, methods &properties provided by Q.T.P AOM. We can develop a program in vb script file. If we execute the program automatically will be open in that one by one tests are

Created by: s.v.s.ramakrishna 36

Page 37: Qtp 9

Q.T.P. M A T E R I A Lopened configured, executed & closed finally Q.T.P also close. We can see the results using test results viewer.

STEPS TO DEVELOP AOM PROGRAM:

Open NotepadWrite statements in the following manner

Save file with .vbs extension

To execute double click on vb script file icon.

AOM:- (Automatic Object Model)

Ex:-

Dim qtaapSet qtaap=createobject(“Quicktest.Application”)qtaap.launchqtaap.visible=trueqtaap.open “f:\\t1”qtaap.test.settings.run.objectsynctimeout=20qtaap.test.runqtaap.test.close

qtaap.open “f:\\t2”------------------------------qtaap.test.close

qtaap.quitSet qtaap=nothing

Navigation To Develop AOM:- Thru SettingsFile---Settings---Select the Required Options in the Tabs (Run, Resources, Environment, Recovery)---Click on Apply Button---Click on Generate Script Button in Properties Tab---Select Location—Click Save Button.

Created by: s.v.s.ramakrishna 37

Page 38: Qtp 9

Q.T.P. M A T E R I A L

RESULT ANALYSIS & REPORTING

Once the test script executed and the application in verify mode we can see result in the result window if the status pass or failed. We can display only the pass statements using filter option.

Navigation:View---Filters---Select Fail Check Box and Deselect remaining check boxes in status section---Click OK.

To Add Defect to Quality Center:Connect Quality Center and Select add defect option, enter defect information finally click on submission button, so that the defect will be added to quality center defect module.

Navigation:Tools---Quality Center Connection---Enter Server URL---Click Connect Btton---Enter User Name & Password---Click Authenticate Button---Select Domain & Project ---Click Login Button---Finally Click Close.

Created by: s.v.s.ramakrishna 38