Pages

Custom Search

Synchronization

Synchronization

It is a process of matching the speeds of both QTP and AUT in order to get proper execution and results.


Where Synchronization is required:

During test execution QTP gives instructions one by one with same speed, but AUT takes less time for some operations execution and more time for some operations execution, that time we may not get proper execution and results. In order to get proper results in between QTP & AUT synchronization is required.

There are several methods available in QTP for synchronization.

1. Inserting Wait statements.
2. Inserting Synchronization points.
3. Increasing Tool default synchronization time.
4. Sync Method (Only for WEB)
5. Exist Property

Inserting Wait Statements:
We can insert wait statements in our test in order to make QTP to wait until AUT completes current operation.
Syntax: Wait(time in seconds)

Note: If we insert wait statements QTP waits up to maximum time even though operation is completed.

Inserting Synchronization points:

Place cursor in desired location>keep tool under recording mode>Insert menu>Synchronization point >show the object >click ok>select property name & Value(True)>enter time in Milli seconds>click ok>Stop recording.

Note: if we insert Synchronization points, it does not wait up to maximum time, after completion of the current operations, it goes to next step immediately.

Syntax: object hierarchy.waitproperty "property name",value,time in milli seconds.

Increasing Tool default synchronization time:

Navigation: File>settings>run tab>increase object synchronization time out>apply>ok
Note: If we increase QTP tool default time that can be applied for all statements in the test, but QTP does not wait up to maximum time unnecessarily, After completion of one statement execution it goes to next statement immediately.

Sync Method: (only for WEB)
Waits for the browser to complete current navigation.

Syntax: Object Hirearchy.Sync
Ex: Browser("Yahoo! Toolbar").Page("Yahoo! Toolbar").Sync

Selecting an appropriate Method:

1. Suppose in our test one or more statements only are taking more time for execution then selecting "Inserting synchronization method" is better.

2. Suppose in our test more statements are taking more time for execution then selecting "increasing tool time out" .

3. Above two are local features but wait statement is Vbscript feature, even though some drawbacks are there in using wait statement, it is better to use wait statement in functions.

Parameterization


Parameterization

Passing parameters, through this  we can pass multiple values.

We use parameterization in Data Driven Testing.

Data Driven Testing: Testing the Same operation with multiple sets of test data.

Types of Parameterization: We can parameterize tests in several ways in QTP

1. Through Loop Statements
2. Dynamic Test Data Submission
3. Through Data Table
4. Fetching Test Data directly from External files (Flat files & Spreadsheets)
5. Fetching Test Data directly from Databases (MSAcess, Oracle etc).
6. Getting Test Data from front end objects.

1. Through Loop Statements: We can use loop statements for passing sequential numbers & Logical Numbers.

Note: We can't generate Strings.

For orderno=1 to 10 step 1 ' for one increment step keyword is not mandatory
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set orderno
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Next

2.Dynamic Test Data Submission: Through Loop Statements we can give strings also but every time user has to enter data.

For x=1 to 3
Agent =inputbox("enter an Agent Name")
Password=inputbox("enter a password")
invokeapplication "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set Agent
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure password
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close
Next

3. Through Data Table: QTP adds one data table (Spreadsheet) for every test, we can use Data Table for Data Driven Testing.



It has 3 types of usage .



a. Entering test data directly into data table and use

b. Importing test data from external Flat files

c. Importing test data from external Spread sheets

d. Importing test data from Data bases.



A. Entering test data directly into data table and use.



Steps: Generate the basic test>open data table(View>Data Table)



Click on column header>enter the name of the field (like this we can create number of columns) > Enter Data>connect the data to test



(variable=datatable("column name", Sheet id)

Example: agent=datatable("agent",1)

Pass parameters.)



Run the test.



Agent = Datatable("Agent",1)

pwd=Datatable ("Password",1)

invokeapplication "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe"

Dialog("Login").Activate

Dialog("Login").WinEdit("Agent Name:").Set Agent

Dialog("Login").WinEdit("Agent Name:").Type micTab

Dialog("Login").WinEdit("Password:").SetSecure pwd

Dialog("Login").WinButton("OK").Click

Window("Flight Reservation").Close





b. Importing test data from external files:



Open Data Table (view>Data table)>place mouse pointer on data table and right click>file>import from file>Click ok>Browsw path of the file(it imports data from the flat file)



Connecting Test Data to QTP Test as above and run the test.



c. Importing test data from external Spread sheets:



Open Data Table (view>Data table)>place mouse pointer on data table and right click>file>import from file>Click ok>Browse path of the excel sheet (it imports data from the excel sheet)



Connecting Test Data to QTP Test as above and run the test.



D. Importing test data from Data bases: Through Data table we can import Test Data from Data bases, but first we have to create /get the DSN(Data source Name)& we have to use SQL Commands.



1. Creating a Test Database: open MS Access (or we can use any other database).



Start programs>MS Office>MS Access>file >new>Select blank Database>enter name of the database>Save with mdb extension.



Creating Tables: Select Create table in design view>Enter field name(Agent)and Select data type(text) Like this we can create number of fields>save&enter table name.



Entering Data into Tables: Select table>enter the data.





Creating DSN & importing data



Navigation: view>data table>Place mouse pointer on Data table>sheet>import>from database(Database query wizard opens)>choose 'specify SQL statements manually>click next >click create>click new>select driver type>click next >browse path to store> enter DSN Name>Click Save>click next>click finish>select>browse the database& select>click ok>click ok>select DSN>click ok>enter SQL statement (select *from login)>click finish.

Note: DSN Creation is one time activity, by using the DSN we can get data for number of tests.

4. Fetching Test Data directly from Flat files

Dim fso, myfile
Set fso=createobject("scripting.filesystemobject")
Set myfile=fso.opentextfile("d:\trigun.txt",1)
myfile.skipline
While myfile.atendofline <> true
x=myfile.readline
S=split(x,"@")

SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set s(0)
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure S(1)
Dialog("Login").WinEdit("Password:").Type micReturn
Window("Flight Reservation").Close
Wend

Fetching Test Data directly from Excel Sheets

Fetching Test Data directly from Databases

Option explicit
Dim con,rs
Set con=createobject("adodb.connection")
Set rs=createobject("adodb.recordset")
con.provider=("microsoft.jet.oledb.4.0")
con.open "C:\Documents and Settings\pooja\My Documents\trigun.mdb"
rs.open "select * from login",con
do until rs.eof=true
SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set rs.fields ("agent")
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure rs.fields("password")
Dialog("Login").WinEdit("Password:").Type micReturn
Window("Flight Reservation").Close
rs.movenext
loop

Inserting Output Values

Inserting Output Values

It is a step in which one or more values are captured during test execution.

The values can later be used as input at a different point in the run session or we can use as input for another test.

It is stored in run time data table; it is located in QTP result window and can be retrieved later.

Types of Output Values:

1.       Standard output value
2.       Text output value
3.       Text area output value
4.       Database output value
5.       XML output value (From Application)
6.       XML output value (From Resource)


1) Standard output value:

 We can use standard output values to output the properties values of most objects.

Navigation:

Keep tool under Recording mode > Insert menu >output value> standard output value > show the object > click ok > select property > modify the column name (if required) > click ok >click ok >stop recording.

2) Text output value:

We can use Text output values to output text strings displayed in an application. When creating a text output value we can output a part of the objects text and we can also specify text before and after options.

Navigation:
Keep tool under recording mode> Insert menu> output value > text output value > show the text >select one of the option(output text/text before/text after) > click modify if you want to change the column name > click ok > click ok.> check in runtime table after running it.

3) Text Area output value:

We can use text area output values to output text strings displayed within a defined area of the screen.

Navigation:

Keep tool under recording mode > insert menu >output value > text area output value >Mark the text area >click modify the column name if necessary > click ok > again click ok > check in run time table after running it..

4) Database output value:

We can use Database output values to output the value of the contents of database cells.

Navigation:

Insert menu> output value > Database output value> choose specify SQL statements manually >click next >click create >Select Machine Data source > Select Driver (QT_flight32) > click ok > enter SQL statement (select *from orders) > click finish > select data cells > click ok > Run and it will capture and see the results in run time table.

5) XML output value (from application):

we can use XML output values to output the values of XML elements in XML documents.

Navigation: Keep tool under recording mode with web environment > Insert menu > output value > XML output value from application > Show the XML document > select elements > click ok >stop recording.

6) XML output Value (From Resource):

We can use XML output values to output the values of   XML elements in XML documents.

Navigation:

Insert menu >output value> XML output value from resource > browse path of the XML file > click ok > select elements >click ok.

Inserting Checkpoints

Inserting Checkpoints

Check point is a verification point, it takes expected result from the user and compares with actual results during execution and provides test results.

There are 11 Checkpoints available in QTP:

1.      Standard check point
2.      Text check point
3.      Text area check point
4.      Bit map check point
5.      Data base check point
6.      Accessibility check point
7.      XML Check point (from Application)
8.      XML Check point (from Resource)
9.      Page check point
10. Image checkpoint
11. Table checkpoint

Note 1: From 6 to 11 checkpoints are only for Web.

Note 2: From 9 to 11 checkpoints are hidden checkpoints, we can insert these checkpoints through standard checkpoint.


1.    Standard Checkpoint:

It checks object property values. We can use this checkpoint for checking any property value.

Navigation for Inserting standard checkpoint

Keep tool under recording mode > place cursor in desired location > Insert > check point > Standard checkpoint > Show the object  > click okay > select property and enter expected results & click Ok and stop Recording.

Navigation for Editing standard checkpoint

Select Checkpoint statement and right click > choose checkpoint properties option > modify the value > click Ok.

Navigation for Deleting standard checkpoint:

Select Checkpoint statements and right click > choose delete option.

Inserting Standard check points through active screen:

View > Active Screen >place cursor in desired location >Place mouse pointer on active screen & right click> choose insert standard checkpoint option > click ok > enter expected result > click ok

Note: Inserting Standard check points through keyword view same as in expert view.

Note: We can insert standard checkpoints in 3 ways.

a.      Through expert view,
b.      Through keyword view,
c.      Through Active screen.

2) Text Checkpoint:

 It Checks object's text property value in different ways.

Navigation:
Keep tool under Recording mode >Insert menu > checkpoint > Text checkpoint > Show the object > click ok > Select options

(Match case; ignore spaces, exact match, text not displayed.)

We can select one or more options > click ok & stop Recording.

3)  Text Area Checkpoint:

It checks the text area present in the application.

Navigation:
Keep tool under Recording mode > Insert menu> Checkpoint > Text area checkpoint > Mark the area of text > select one or more options

(Match case, ignore spaces, exact match, text not displayed.)

Click ok and stop recording.

4.      Bitmap checkpoint:

It compares bitmaps; we can compare complete bitmaps as well as part of the bitmaps.

Navigation:

Keep tool under Recording mode > Insert menu > Checkpoint > Bitmap checkpoint > show the Bitmap >click ok >select "check only selected area" option if we want to compare part of the bitmap > click ok >stop recording.

5.      Database checkpoint:

It checks Content of the back end Database.

Navigation:
Insert > checkpoint > Database checkpoint >choose "specify SQL statement manually" option >click next > click create > select machine data source > Select DSN (QT_flight32) > click ok > enter SQL statement (select * from orders) > finish > click ok.

Note: here we do not need to put tool under Recording mode and we do not need AUT since data is from backend.

6.      Accessibility check point:

It checks whether the webpage in our web application is developed according to W3C (World Wide Web consortium) Rules and Regulations or not.

It is a configurable checkpoint, according to our requirements, we can customize.

Configuring accessibility checkpoint:

Tools menu> options >web > advanced > check/uncheck items > click apply > click ok

Invigilation:
Keep tool under recording mode with web environment >insert>checkpoint>accessibility checkpoint>show the webpage>click ok>click ok>stop recording.

Result Criteria:
a)     If item is available but not according to W3C rules then fail.
b)     If an item is available, according to W3C rules then Pass.
c)     If an item is not available then result would be pass

7. XML Check point (from Application)

It checks content of the XML file.

Navigation:
Keep tool under Recording mode in web environment > insert menu > checkpoint (from application)> show the xml pages >click ok > stop Recording.

8. XML Check point (from Resource)

It checks content of the XML file.

Navigation: Insert menu > checkpoint >xml checkpoint (from resource) > browse path of the XML File > click ok > click ok.

Note: 1. If XML file is an individual and path available, and then we can go for inserting xml checkpoint from resource.

Note: 2. If XML file is part of web application, separate path is not available then we can choose inserting XML checkpoints from application.

9. Page checkpoint:

    It checks number of Links, Images and Loading time in a web page.

    It is a hidden checkpoint; we can insert this through standard checkpoint.

    Navigation:

    Keep tool under Recording mode with web environment > Insert menu > checkpoint > Standard checkpoint >show the web page > click ok > click ok > stop recording.

    10. Image checkpoint:

    It checks Image property values.

    Navigation:
     Keep tool under Recording mode with web environment > Insert menu > checkpoint >standard checkpoint > show the image > select image > click ok > click ok >stop recording.

    11. Table checkpoint:

    It checks content of the web tables.

    Navigation: Keep tool under Recording mode under web environment > Insert menu > checkpoint > standard checkpoint >show the web table > click ok >stop recording.

    Descriptive Programming

    Descriptive Programming

    Entering / Providing objects information directly into the test script is called Descriptive Programming.

    In this method of script creation, we no need to have Object Repositories.

    Advantages:

    a) Descriptive Programming based Test scripts are faster in execution than Repository based Test scripts.

    b) Scripts are portable (we can run these scripts from any machine easily)

    c) Maintenance is easy (less amount of resources)

    d) We can start Test Execution process even though Application is not ready.

    Descriptive programming is basically 2 types.

    1. Static Programming
    2. Dynamic Programming

    Static Programming

      In this style of script generation, we provide objects information directly into the script.

    Example:
    1) Invokeapplication "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
    2) dialog("text:=Login").Activate
    3) dialog("text:=Login").Winedit("attached text:=Agent Name:").Set "gcreddy"
    4) dialog("text:=Login").Winedit("attached text:=Password:").Set "mercury"
    5) dialog("text:=Login").Winbutton("text:=OK","width:=60").Click

    Note:
    1. Dialog, WinEdit and WinButton – Test Objects
    2. text, attached text - Property names
    3. Login, Agent Name:, Password:, OK - Property values or Logical Names of the Object
    4. Activate, Set, Setsecure, Click - Methods

    Note2:
    If we feel one property information is not sufficient for recognizing the object uniquely, then we can provide more properties information by separating with commas.

    Note 3:
    If we want to get objects information (Test objects, properties and values), we can use object spy feature. This feature is available in Tools Menu, in local repository and in repository manager.

    Example 2:
    SystemUtil.Run "C:\Program Files\Internet Explorer\IEXPLORE.EXE","","C:\Program Files\Internet Explorer","open"
    Browser("title:=Google").Page("title:=Google").Sync
    Browser("title:=Google").Navigate "http://www.icicibank.com/"



    -------------------------------------------------------------------
    If we want maintain 'Objects information' in centralized location then we can use Constants.

    Steps:

    Creating Constants:

    Const Login="text:=Login", Agent="attached text:=Agent Name:"

    Const Pwd ="attached text:=Password:", Ok="text:=OK"

    Note: we can declare no of Constants in a line by separating with Camas (,), if we take other line then we have to use Const Statement again.

    Creating a Library file

    Place Constants in Notepad and save as .vbs file

    Associate the Library file to QTP (File->Settings->Resources-> Click add (+) icon-> Browse path of the Library file->Click Apply and click Ok buttons

    Otherwise, we can load the library file during run-time

    Syntax:

    ExecuteFile "Path of the Library file(.vbs)"

    After that create the Test Script using Constants

    Creating the Test Script using Constants:

    Invokeapplication "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
    Dialog(Login).Activate
    Dialog(Login).Winedit(Agent).Set "asdf"
    Dialog(Login).Winedit(Pwd").Set "mercury"
    Dialog(Login).Winbutton(Ok).Click

    Advantages:

    If we maintain Object Information in the centralized location, then we can handle modifications easily.
    -------------------------------------------------------------------

    Dynamic Programming

    In this style of script generation, first we create description objects, provide properties information and use description objects in the test script.

    Creating Properties Collection Objects

    Set oLogin=description.Create
    Set oAgent=description.Create
    Set oPassword=description.Create
    Set oOk=description.Create

    Entering Properties Information into Objects

    oLogin("text").value="Login"
    oLogin("width").value=320
    oLogin("height").value=204
    oAgent("attached text").value="Agent Name:"
    oPassword("attached text").value="Password:"
    oOk("text").value="OK"

    Generating Tests using Properties collection Objects

    Invokeapplication "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"

    Dialog(oLogin).Activate
    Dialog(oLogin).Winedit(oAgent).Set "gcreddy"
    Dialog(oLogin).Winedit(oPassword).Set "mercury"
    Dialog(oLogin).Winbutton(oOK).Click

    Note1: Create Description objects and put into one library file, by associating that library file, we can generate tests.

    Note2: Dynamic programming is some difficult in preparation than static programming but maintenance is very easy.

    ------------------------------------------------------
    Examples:

    Handling similar/Duplicate Objects using Index Property

    SystemUtil.Run "C:\Program Files\Internet Explorer\IEXPLORE.EXE"

    Browser("name:=Google").Page("title:=Google").Sync

    Browser("name:=Google").Navigate http://www.jjperfumes.com/

    Browser("name:=JJ Perfumes-Discount perfume cheap brand name perfumes, fragrance & cologne online").page("title:=JJ Perfumes-Discount perfume cheap brand name perfumes, fragrance & cologne online").Link("innertext:=Register","index:=0").Click

    QTP Data Table Methods

    QTP Data Table Methods
    (1) Add Sheet:
    We can use this method to "add" one new sheet to the run time data table.
    Syntax: DataTable.AddSheet "sheet name"
    Ex: DataTable.AddSheet "gcreddy"

    (2) Delete Sheet:

    We can use this method to "delete" one specified sheet from the Run Time Data table.


    Syntax: datatable.DeleteSheet (Sheet_ID)
    Ex: datatable.DeleteSheet (3)


    (3) GetSheetCount


    We can use this method to count number of sheets in the run time data table.


    Syntax:
    datatable.GetSheetCount
    msgbox datatable.GetSheetCount

    (4) GetRowCount


    We can use this method to count number of rows in the 1st sheet
    (longest column) of the Run time data table.


    Syntax: datatable.GetRowCount


    Ex: msgbox datatable.GetRowCount

    (5) GetSheet


    We can use this method to return a specified sheet from the Run Time data table.


    Syntax: datatable.GetSheet(SheetID)


    Ex: msgbox datatable. GetSheet(1).GetRowCount


    (6) Value

    We can use this method to set or get value of cell in the specified parameter and the current row of the Rum time data table.


    To set data


    Syntax: datatable.Value(Parameter_Name, Sheet_Name) = Value / variable Or

    datatable(Parameter_Name, Sheet_Name) = Value / variable


    To get data

    Syntax: Variable = datatable.Value(Parameter_Name, Sheet_Name) Or

    Variable = datatable(Parameter_Name, Sheet_Name)


    Ex:

    Option explicit Dim a, b, c


    a=datatable.Value (1,1) b=datatable.Value (2,1) c=cint(a)+cint(b) datatable.Value (3,1) = c

    Note: Default property of Datatable is value

    (7) SetCurrentRow


    We can use this method to take a specified row as current row in the Run Time Datatable (By default it is 1st Row of 1st Sheet)

    Syntax: datatable.SetCurrentRow(Row_Number)

    g="gcreddy"

    datatable.SetCurrentRow (3) datatable.Value (1,1) = g


    (8) SetNextRow


    We can use this method to take the row after the current Row as New Current Row in the Run time data table.


    Syntax: datatable.SetNextRow

    Ex: g="gcreddy"

    datatable.SetCurrentRow (3) datatable.SetNextRow datatable.Value (1,1) = g


    (9) SetPrevRow

    We can use this method to take the row before the current Row as New Current Row in the Run time data table.


    Syntax: datatable.SetPrevRow


    Ex: g="gcreddy"


    datatable.SetCurrentRow (3) datatable.SetPrevRow datatable.Value (1,1) = s


    (10) Import

    We can use this method to import Microsoft Excel File to the Runtime Data Table (Including all sheets)


    Syntax: datatable.Import "Path of File"

    Ex: datatable.Import "F:\Inputdata.xls"

    11) ImportSheet

    We can use this method to import a specified sheet of Microsoft Excel Sheet to the Runtime Data table.


    Syntax: datatable.ImportSheet "Path of File", "Source Sheet", "Destination Sheet"

    Ex: datatable.ImportSheet "E:\gcreddy.xls",3,1

    (12) Export


    We can use this method to export a copy of Run Time Data table to another location (Including all sheets)


    Syntax: datatable.Export "Path of File"


    Ex: datatable.Export "F:\gcreddy.xls"


    13) ExportSheet


    We can use this method to export a copy specified sheet of Run Time Data table to the existing or new Excel File.

    Syntax: datatable.ExportSheet "Path of File", "Sheet Name / Source Sheet"


    Ex: datatable.ExportSheet "F:\gcreddy.xls", 2

    **********************
    Data Driven Testing for Login Operation using Data Table methods

    Datatable.AddSheet "Login"
    Datatable.ImportSheet "C:\Documents and Settings\gcr\Desktop\gcreddy.xls",1,3
    Rows_count=Datatable.GetSheet(3).GetRowCount

    For i= 1 to Rows_count
        Datatable.SetCurrentRow(i)
    SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\HP\QuickTest Professional\samples\flight\app\","open"
    Dialog("Login").Activate
    Dialog("Login").WinEdit("Agent Name:").Set Datatable("Agent",3)
    Dialog("Login").WinEdit("Password:").Set Datatable("Pwd",3)
    Dialog("Login").WinButton("OK").Click

    If window("Flight Reservation").exist(10) Then
        Login="Login Operation Successful"
        Datatable("Result",3)=Login
        Reporter.ReportEvent micPass,"res","Passed"
        else
    Reporter.ReportEvent micFail,"res","Failed"
    Login="Login Operation Failed"
    Datatable("Result",3)=Login

    Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
    Dialog("Login").WinButton("Cancel").Click
    End If

    If Window("Flight Reservation").Exist(3)Then
        Window("Flight Reservation").Close
        End if
    Next

    QTP Methods

    QTP Methods

    Activate: It activates dialog boxes/Windows
    Syntax: Object hierarchy. Activate
     Ex:
    Dialog("Login").Activate
    Window("Flight Reservation").Activate

    Click Method: It clicks on an object (Buttons)
    Syntax: Object hierarchy. Click
    Ex:
    Dialog("Login").Winbutton("ok").click

    Close Method: It closes the window,Dialog box, Browser window etc.
    Syntax: Object hierarchy. Close
    Ex:
    Window("Flight Reservation").Close
    Browser("Browser").Close

    Dblclick: It Double clicks the object.

    Set Method: It can be used in three ways.
    a. For setting the value of an edit box
    Syntax: Object Hierarchy. SET "Value"
    Ex: Dialog ("Login").WinEdit("Agent Name").Set "asdf"

    b. Selecting a Radio Button
    Syntax: Object Hierarchy. Set
    Ex: Window("Flight Reservation").WinRadioButton("Business").Set

    c. Selecting/Deselecting check boxes
    Syntax:object Hierarchy.Set "ON/off"
    Ex: Window ("Flight Reservation"). Dialog("Open Order").WinCheckBox("Order No.").Set "ON"

    Select Method:
    It is used for selecting an item from a combo box or list box.
    Syntax: Object hierarchy.select "item"
    Ex:
    Window("Flight Reservation").WinComboBox("Fly From:").Select "London"
    Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "12572

    GetVisibletext: It returns Text from the specified area.
    Syntax: Variable =object hierarchy.getvisibletext
    Ex:
    x=Window("Flight Reservation").WinComboBox("Fly From:").GetVisibleText
    msgbox x

    GetRoproperty:
    It returns current object property value. It can be used for getting any object's, any property value.
    Syntax: Variable = object hierarchy.getroproperty ("property name")
    Ex: x=Window("Flight Reservation").WinEdit("Tickets:").GetROProperty ("width")
    msgbox x

    Navigate Method:
    It opens a specified URL in the Browser.
    Syntax: object hierarchy.navigate "URL"
    Ex: Browser("Yahoo!").Navigate http://www.google.co.in/

    Getitemscount: It returns number of items in a combobox.
    Syntax: Variable=object hierarchy.getitemscount
    Ex: x=Window("Flight Reservation").WinComboBox("Fly From:").GetItemsCount
    msgbox x

    Getcontent: It returns all items from a combobox.
    Syntax: variable=object hierarchy.GetContent
    Ex: x=Window("Flight Reservation").WinComboBox("Fly From:").GetContent
    msgbox x

    Exist property: It checks whether the object is available or not.
    Syntax: Object hierarchy.exist(time in seconds)
    Ex: Window("Flight Reservation").Exist(5)

    Object Identification Configuration

    Object Identification Configuration
    Overview:

    Generally for every object 20-25 properties information available, qtp recognizes object using 2 0r 3 important properties.

    Qtp has default object identification configuration for every environment, if we feel that config is not sufficient for recognizing objects in our application, we can configure some more

    Object Identification Types


    a)    Normal identification

    1)   Mandatory properties
    2)   Assistive properties

    b)    Smart identification

    1)    base filter properties
    2)    optional filter properties

    c)    Ordinal identifier
     
    1)    location
    2)    index
    3)    creation time(only for web)

    QTP learns information in the following in case of normal identification:
     

    First of all the qtp learns all the mandatory properties at a time and thinks whether these properties sufficient to identify the object uniquely. if it feels sufficient then it stops learning otherwise,
    It learns first assistive property and once again stops and thinks, like this qtp learns one by one. At the end of assistive properties list also if it feels not satisfied and it finally goes to Ordinal Identifier.


    QTP learns information in the following in case of Smart Identification:

    Smart identification is an optional feature, if we feel normal identification is not sufficient for any object, and then we configure Smart Identification for that object, in order to avoid Ordinal Identifier.

    After normal identification if qtp feels not satisfied then it goes to smart identification. in smart identification 2 types of properties available, first qtp learns all base filter properties at a time and thinks whether these properties are sufficient for identifying the object uniquely. If it feels sufficient, then it stops learning otherwise it goes Optional Filter Properties and learns one by one. Still it feels not satisfied finally it goes to Ordinal Identifier.

    Ordinal identifiers:

    There are 3 types of ordinal identifiers available

    1) Location: is based on object location in the AUT ,location starts from zero.
     
    2) index: it is based on sequence of the programs, index starts from zero
     
    3) Creation time: it is based on loading time of the web objects. qtp generates 0,1,2 like numbers.

    Tool Settings Globalization:

    As QTP is a I-tier(Stand-alone) application,making Tool settings globally is not possible.


    For making tool settings global, QTP is providing a special feature called "Generate Script".

    STEPS:

    1) Settings available in 3 areas.
        

        a) File->Settings
        b) Tools->Options
        c) Tools->Object Identification

    2) Perform required settings and generate Scripts

    3) Share Script files to team members and ask them to execute those scripts.

    NOTE: After executing these scripts all team members can get same settings.

    Object Repository

    Object Repository

    Object Repository:
    It is a storage place of QTP where objects information can be stored and it also acts as interface between the Test script and the AUT in order to identify the objects during execution.

    Object:
    Object is something, which has structure and properties.

    Software objects:
    We call Windows, Web Pages, Buttons, Edit boxes, Check boxes etc.. as software objects.

    Types of Object in QTP:
    There are four types of object available in QTP.

    1. Run time objects
    2. Test objects
    3. Utility objects
    4. Automation objects/User defined objects.

    Run time objects: The objects present in the AUT. Ex: Buttons, Links, etc…

    Test Objects: References of Run time objects. Ex: WinEdit, WinButton, WebButton, Link, etc…

    Note:
    Test objects names vary from one environment to another.

    Utility objects

    They are QTP reserved objects used for Testing and Result reporting.

    Ex:
    1. SystemUtil for launching/closing the application.
    2. Reporter for defining results.
    3. Services for inserting transaction points
    4. Environment for using environment variables

    Automation objects/User defined objects

    User can create objects; those can be used for performing specific operations. Ex: Creating objects in filesystemobject class, adodb.connection class, dictionary object class, Excel. Application class etc.

    There are two types of repository available in QTP.

    1. Local repository (.MTR extension)
    2. Shared repository(.TSR extension)

    Local Repository:
    QTP creates a Local Repository for every Action automatically during Recording. That cannot be shared among tests.

    User can add some more objects to Local repository

    User can perform rename, delete operations on local repository. As it is QTP internal file user no need to save modifications.

    Shared Repository:
    User (Test Engineer) creates the Shared Repository by adding objects. That can be shared among number of tests.

    Using this method user can perform modifications on objects easily.

    Operations on Object Repository

    Adding objects
    a. Local Repository:

    Navigation: open Local Repository (Resource Menu > Object Repository)

    objects>Add objects to Local> Show the Object>Click Ok

    (No need to save separately, it saves automatically)

    B. Shared Repository:

    Navigation: Resource menu>object repository manager>object>Add objects>show the window/object>click ok

    o Selected object only
    o Default object types
    o All objects types
    o Selected object types

    (If we select first option it stores Selected objects only, if we select second option it stores all default objects, if we select third option it stores All objects including static objects, if we select fourth option, we have to select object classes then it stores that class objects, we can select more than one class also.)

    Renaming Objects

    a. Local Repository:

    Resources > object repository >select object and right click >choose rename option >modify the name>release the mouse.>close repository

    b. Shared Repository:

    Resources >object repository manager>file>open>browse path of the repository file >file>enable editing>select object &Right click>choose rename option>modify the name > release mouse>save the file & close repository manager.

    Deleting Objects

    a. Local Repository:

    Resources > object repository >select object and right click >choose delete option >confirm deletion>. >close repository

    b. Shared Repository:

    Resources >object repository manager>file>open>browse path of the repository file >file>enable editing>select object &Right click>choose delete option>confirm the deletion >save the file & close repository manager.

    Associating Object Repositories to an Action/Test

    Resources>Associate repositories>click add icon (+)>browse path of the repository>Associate with an action>click ok

    Merging Repositories

    Resources > object repository manager>tools>object repository merge tool >browse path of the first repository> browse path of the second repository>click ok>click close>save the merged repository>close the repository manager.

    Note: After merging also, source repository files will be available, if we do not want source files we can delete.

    Defining New Test Objects

    Navigation: Object>Define new test object >Select Environment>Select Class of the object>Enter name of the object>Click Add>click close>Select object >select property name>enter value (like this select one by one properties and enter values)>save

    Note: This feature can be used for preparing tests before the AUT is ready.

    Spying Objects

    For getting objects information, (Test objects names, property & Values) QTP is providing a feature called Object Spy, using this we can get objects information.

    Navigation>Tools>object spy>take hand icon & Show the object>get information (Object Spy shows the specific objects all available properties with their values)

    Note: As Object spy is an important feature, it can be available in 3 Areas.(1. In tools Menu 2. In local repository 3. In Repository manager)

    View Options

    Locate in Repository

    This feature can be used for identifying objects from application to repository.

    Navigation: View>Locate in repository >show the object>click Ok>it locates specified object in the repository.

    Highlight in Application

    This feature can be used for identifying objects from repository to application.

    Navigation: Select object in the repository >view>highlight in application>it highlights specified objects in the application.

    Exporting Repository to an XML file

    We can export our repository file to an xml file.

    Navigation: File >export Test objects to XML Enter the file name and Save with xml extension.

    Importing Repository from XML file.

    We can import XML file to our repository.

    Navigation: File>import from XML >browse path of the XML file >it loads objects.

    Note: The purpose of this feature is Editing objects information outside of the QTP

    Navigation: Resource menu>object repository (Short cut key Ctrl+R)