12 Dec 2012

Utility Objects


Utility Objects

"Utility" objects are the Reserved objects in QTP and can be used for Testing and Result Reporting preferences during a run session


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 and so on...
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()                   'Create a description for a webEdit'
 W_Edit("name").Value="q"                         'Provide the value for that Webedit by using Object spy'

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'
wait(2)

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") 'This will show the newly created parameter in the run-time Data Table '
    msgbox Show_Param

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") 'This will take the sheet Id & it will add the parameter to that sheet'
     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    'It creates a new internal user-defined variable named My_Var with a value of 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") 'The given argument is the name of the action parameter for which we want to retrieve the value '
     Msgbox Par_Val

No comments:

Post a Comment