DotNetFactory
This utility object is available from QTP 9.2 onwards and all the versions after 9.2,
This utility object you can see in Insert menu--->Step Generator---->utility object Category---->Select in Object List
This Object Provides QTP scripting to access methods and properties of a .NET object by creating an instance for this object.
Syntax :
Dim d
set d=CreateInstance(Typename,assembly,parameters)
Typename : name of the object
assembly (optional): if it is already preloaded assembly then no need to specify else we have to specify the assembly ie. the DLL which has the typename
parameters: specify the parameters if typename has any input parameters.
Note : Refer in msdn.microsoft.com for all the System Namespace and its classess, .Net Class Library list,,, below is the link
http://msdn.microsoft.com/en-us/library/d11h6832(v=VS.71).aspx.....
Few Examples :
Example 1:
' Display our own message Created from System.Windows.Forms.MessageBox --Typename ,, which belong to System.Windows.Forms Assembly
Dim msg
Set msg = DotNetFactory.CreateInstance("System.Windows.Forms.MessageBox", "System.Windows.Forms")
msg.show "This is Venkat","Sample"
--------------------------------------------------
Example :2
'Display our own window /Form
Dim frm1
Set frm1 = DotNetFactory.CreateInstance("System.Windows.Forms.Form", "System.Windows.Forms")
frm1.Text = "Venkat"
frm1.Maximizebox = True
frm1.Minimizebox = True
frm1.Width = 500
frm1.Height =200
frm1.Location.X = 50
frm1.Location.Y = 200
frm1.Show
---------------------------------------
This utility object is available from QTP 9.2 onwards and all the versions after 9.2,
This utility object you can see in Insert menu--->Step Generator---->utility object Category---->Select in Object List
This Object Provides QTP scripting to access methods and properties of a .NET object by creating an instance for this object.
Syntax :
Dim d
set d=CreateInstance(Typename,assembly,parameters)
Typename : name of the object
assembly (optional): if it is already preloaded assembly then no need to specify else we have to specify the assembly ie. the DLL which has the typename
parameters: specify the parameters if typename has any input parameters.
Note : Refer in msdn.microsoft.com for all the System Namespace and its classess, .Net Class Library list,,, below is the link
http://msdn.microsoft.com/en-us/library/d11h6832(v=VS.71).aspx.....
Few Examples :
Example 1:
' Display our own message Created from System.Windows.Forms.MessageBox --Typename ,, which belong to System.Windows.Forms Assembly
Dim msg
Set msg = DotNetFactory.CreateInstance("System.Windows.Forms.MessageBox", "System.Windows.Forms")
msg.show "This is Venkat","Sample"
--------------------------------------------------
Example :2
'Display our own window /Form
Dim frm1
Set frm1 = DotNetFactory.CreateInstance("System.Windows.Forms.Form", "System.Windows.Forms")
frm1.Text = "Venkat"
frm1.Maximizebox = True
frm1.Minimizebox = True
frm1.Width = 500
frm1.Height =200
frm1.Location.X = 50
frm1.Location.Y = 200
frm1.Show
---------------------------------------
Comments
Post a Comment