QTP Provides the several utility objects to enhance the power of scripting.Utility Objects are the reserved objects in QTP.These objects can be used in reporting preferences during run time.
There are various Types of Utility Objects:
1)Crypt Object
2)DataTable Object
3)Description Object
4)DotNetFactory Object
5)DTParameter Object
6)DTSheet Object
7)Environment Object
8)Extern Object
9)LocalParameter Object
10)MercuryTimers Object (Collection)
11)MercuryTimer Object
12)Parameter Object
13)PathFinder Object
14)Properties Object (Collection)
15)QCUtil Object
16)RandomNumber Object
17)Recovery Object
18)Reporter Object
19)RepositoriesCollection Object
20)Repository Object
21)Services Object
22)Setting Object
23)SystemMonitor Object
24)TextUtil Object
25)TSLTest Object
26)XMLUtil Object
Lets discuss some of them :-
1) Crypt Object
It is used to encrypt a string which can be protected .It uses the Encrypt method .
Ex: User_Name=Crypt.Encrypt("Jhon") 'It will show the string in a encrypted format'
Msgbox User_Name
2) DataTable Object
It is used to retrieve the values from the datatable.It uses different methods like a)AddSheet b)DeleteSheet c)Export d)ExportSheet e)GetCurrentRow f)GetRowCount etc .
Ex: DataTable.GlobalSheet.AddParameter "Name","James"
3)Description Object
Generally description object is used to store a set of properties for a particular class which can be accessed by description object.
Ex: Set W_Edit=Description.Create()
W_Edit("name").Value="q"
Browser("Google").Page("Google").WebEdit(W_Edit).Set "Mindfire"
4)DotNetFactory
DotNetFactory is used to create an instance of .Net Objects and access its methods and properties.Its associated method is CreateInstance method.
Ex: Set Create_Form = DotNetFactory.CreateInstance("System.Windows.Forms.Form", "System.Windows.Forms") 'It will create an instance of a blank Windows form object'
Create_Form.Show 'It displays the form on the screen'
5)DTParameter Object
It is a parameter which can be accessed during run time by following methods or properties:
>DTSheet.AddParameter
>DTSheet.GetParameter
Ex:Show_Param=DataTable.LocalSheet.AddParameter("UserName","Mindfire")
msgbox Show_Param
6)DTSheet Object
It is a Sheet which can be accessed during run time by following methods or properties:
>DataTable.AddSheet
>DataTable.GetSheet
>DataTable.GlobalSheet
>DataTable.LocalSheet
Ex: Show_Param=DataTable.GetSheet("mysheet").AddParameter("UserName","Mindfire")
msgbox Show_Param
7)Environment Object
QTP Environment variables are special type of variables whose values persist across and are shared by all actions in a test.QTP environment variables can be used to share information across actions,recovery scenarios and libraries.
Ex: Environment.Value("My_Var")=10
My_Var=Environment.Value("My_Var")
8)Extern Object
Extern is a reserved object in QTP which is instantiated and is used to call external procedures from an external dynamic-link library (DLL).Its associated method is Declare().It is used as a reference to external procedures in DLL.
9)LocalParameter Object
A local Parameter is used to parametrize the value of a step in a business component.
Ex: Par_Val=Parameter.Item("UserName")
Msgbox Par_Val
No comments:
Post a Comment