Professional Documents
Culture Documents
Method : Method is some thing which is used by QTP to Perform any action is called a method.
Example : Click, set …. Etc
1. Capture Bit Map() : This method used for capturing a snap shot of an object during Execution and stores
in a desired location. When you want to send Defect to the developer, this captured bitmap
can also be sent in order to understand the error/defect easily.
Syntax : Object Hierarchy. captureBitmap “path of the location with a file name .bmp extension”
2. Exist () : The main purpose of this method is to check whether the object/ window is existing or NOT.
Exist method is used for checking the object’s existence. If the object is existing
then it will return TRUE and continue the execution. Otherwise , it will wait till the object exists or
upto the maximum time. Meanwhile at any point of time the object exists it will return TRUE and
continue its execution, otherwise, after the maximum time is finished it will return FALSE and
continue its execution.
* Exist method will make the QTP to wait till the default time Plus extra time (if any)
3. WaitProperty () : This method is used for make the tool to wait based on the object property’s value or
up to maximum time .
Syntax : Object Hierarchy. Waitproperty “propertyName”, Property value, extra time in milliseconds
Example :
Open the flight application and put tool in recoding mode
Open the order by clicking on open order, it will displays the open order window
Enter an existing order number and click on Ok. That order will be opened.
Stop recording.
Now , if you want to wait the tool even after clicking on OK button
take the property name ( as text),value( as OK) from object repository and put extra
time in milliseconds.
For example : OH.WaitProperty "text", OK,10000
And put the above code after the OK button clicked statement in the script
Run the test
Analyze the results
4. Wait () : This method is used for making the tool to wait till the maximum time is elapsed
Example :
Example :VbWindow(“Emp”).VbRadioButton(Location).Set
4. Select Method: Which is used for selecting an item in a ComboBox or List
Syntax : Object Hierarchy. Select “item”
Example :
5. Set Secure Method: Which is used for setting the encrypted data into the edit box.
* Encrypted string can be generated with help of a tool “password encoder”.
Navigation for password encoder : Start -> Programs -> QTP -> Tools -> Password encoder
Example : *********
Example :
8. Type Method: Which is used for performing any kind of keyboard related operations.
Syntax : Object Hierarchy. Type keyvalue
Example : ggggg
Important Methods
RO ( Runtime Object ): Runtime object is the original object that was presented in the application (AUT).
TO ( Test Object ) : Test object the Reference of original object stored in the object repository and
used for identifying the original object in the AUT during the execution.
1. Get RO Property : This method is used for getting the Runtime Object property’s value
Text
Width etc…..
Note : By using getROproperty method we can avoid the standard checkpoint, because, the check points will
create an “internal file” which is a over burdon the execution and takes the memory to store that files.
OK
Else
Reporter.ReporterEvent 3, “myreporter”, “OK Button doesn’t existing” : 3=worning
End if
* This is the only script that we generated by tool and remaining thing is the enhancement to that script
done manually by test engineer.
2. Get TO Property : This method is used for getting the Test Object’s properties value.
Text
Width etc…..
Example :
var = VbWindow(“form1”).VbButton(“ADD”).GetTOproperty(“Text”)
Note : The properties that are learnt during the learning time are called Test Object Properties
Test Object Property = Properties presented in object Repository
+
Properties presented in secret place (smart brain ) if any.
Test object is a Reference of runtime objects which are stored in Object Repository and in
smart brain (if smart brain is enabled).
Whatever all the Properties Learnt during the learning time are called Test Object Properties.
When with help of Get RO properties its self we can get all the properties in an AUT ? Why Get RO and
Get TO properties?
Get RO property will be used to capture the all the properties’ present values of objects in
AUT during the Learning Time
where as Get TO property will be used to capture the all the properties’ present value of
objects in AUT during the execution time.
For example : In a application OK button is disabled by default ( This RO property) but when
entering some data therein the OK button will be enabled( This TO property).
3. Set TO Property : This method is used for Setting the Test Object’s properties value temporarily
during the execution.
Text OK
Width etc….. Start …..
Example : for clicking on same button for Start-Stop-Start. Assume that initially the button is named with Start
and want to be Stop when its clicked. And again if its clicked, it should be Start.
1St rename the button name as B1 in Object repository so as to don’t effect other buttons.
VbWindow(“form1”).VbButton(“B1”).Click
VbWindow(“form1”).VbButton(“B1”).SetTOproperty “text”, “stop”
VbWindow(“form1”).VbButton(“B1”).Click
VbWindow(“form1”).VbButton(“B1”).SetTOproperty “Text”, “Start”
Simple VB Script functions used for Calculation and Comparison :-
Script :
• All Data Table Methods are used in Runtime data table ONLY i.e we can’t do any thing with Design
time data table.
• For every action a corresponding Sheet will be created in both data tables but only one Global sheet
for each data table.
• In order to maintain test data clearly, simply and user friendly we Maintain each sheet for each
corresponding action.
• Sheet can be inserted along with action only.
• If you want to import data to Runtime data table , you need to add sheet manually in the same.
Local Sheet : In local sheet the focus will be on 1st row itself only
Global sheet : In global sheet for every iteration the focus need to change on next row and so on.
Methods :-
1. AddSheet() :- It is used for adding an extra sheet to the Run Time data table
Syntax : Datatable.AddSheet “Sheet Name”
2. DeleteSheet() :- It is used for deleting a specified sheet from the Run Time data table
Syntax : Datatable.Deletesheet “sheet name”
3. Import() :- It is used for importing the data presented in all the sheets in a xl file to the RTDT
Syntax : Datatable.import “path of the .xls file”
4. ImportSheet() :- It is used for importing the data presented in a specified sheet in the xl file to the
specified sheet in Run Time Data table.
Syntax : datatable.ImportSheet “path of the xl file”, Source sheet ID, Destination Sheet ID
5. Export() :- It is used for exporting the data presented in Run time data table to a specified laction.
Syntax : datatable.Export “path of the location with a file name .xls extension”
6. ExprotSheet() :- It is used for exporting the data presented in a specified sheet in Run time data table
to a specified location
Syntax : datatable.ExportSheet “Path of the location with a file name .xls extension” , Sheet ID to be exported
7. SetCurrentRow() :- It is used for making the QTP focus on a specified row
Syntax : datatable.SetCurrentRow(Row number)
8. SetNextRow() :- It is used for making the QTP focus on the Next row of Currently focused row
Syntax : datatable.SetNextRow
9. SetPreRow() :- It is used for making the QTP focus on the previous row of the currently focused row.
When this method executes, the cursor will go to the last row of the table and moves
upward one by one row till it reaches to 1st row in the table.
Syntax : datatable.SetPrevRow
10. GetSheet() :- It is used for making the QTP focused on a specified sheet.
Syntax : datatable.GetSheet( Sheet Id)
11. Value() :- It is used for getting a value from a specified sheet, specified column and currently focused row.
Syntax: datatable.value(“column name”,sheet Id)
12. GetRowCount() :- It is used for getting the row count of the global sheet by default. If at all one wants
the row count of a specified sheet , then, First he needs to focus on the sheet and
then get the row count.
Syntax 1 : variable=datatable.GetRowCount
Syntax 2 : variable= datatable.GetSheet.GetRowCount
Example : For add data sheet, import data to datasheet, ADD the two values, pass the result to data sheet, export
the data sheet to log folder.
Run
Analyze the result
-: The End :-
Pls. leave your feed back (both +ve and –ve ) at kanakadria@yahoo.co.in