Showing posts with label DotnetFactory. Show all posts
Showing posts with label DotnetFactory. Show all posts

Tuesday, 26 June 2012

An Example of DotNetFactory in QTP

An Example of DotNetFactory in QTP

Function DotnetUIDPWDForm(strDetails)
 'Creating instances of DotNetfactory objects
Set frmProd = DotNetFactory.CreateInstance("System.Windows.Forms.Form", "System.Windows.Forms")
Set lblDBDetails  = DotNetFactory.CreateInstance("System.Windows.Forms.Label", "System.Windows.Forms")
Set lblUID = DotNetFactory.CreateInstance("System.Windows.Forms.Label", "System.Windows.Forms")
Set txtUID = DotNetFactory.CreateInstance("System.Windows.Forms.TextBox", "System.Windows.Forms")
Set lblPWD = DotNetFactory.CreateInstance("System.Windows.Forms.Label", "System.Windows.Forms")
Set txtPWD = DotNetFactory.CreateInstance("System.Windows.Forms.TextBox", "System.Windows.Forms")
Set btnSubmit = DotNetFactory.CreateInstance("System.Windows.Forms.Button", "System.Windows.Forms")

Set oPoint = DotNetFactory.CreateInstance("System.Drawing.Point", "System.Drawing", x, y)

oPoint.x = 10
oPoint.y = 10
lblDBDetails.Location = oPoint
lblDBDetails.Width = 350
lblDBDetails.Height = 70
lblDBDetails.Text = strDetails

oPoint.x = 10
oPoint.y = 80
lblUID.Location = oPoint
lblUID.Text = "PROD User ID"

oPoint.x = 10
oPoint.y = 110
lblPWD.Location = oPoint
lblPWD.Text = "PROD Password."

oPoint.x = 150
oPoint.y = 80
txtUID.Location = oPoint
txtUID.Width = 100

oPoint.x = 150
oPoint.y = 110
txtPWD.Location = oPoint
txtPWD.Width = 100
txtPWD.UseSystemPasswordChar=true

oPoint.x = 150
oPoint.y = 150
btnSubmit.Location = oPoint
btnSubmit.Width = 100
btnSubmit.Text = "Submit"
     
'Add Controls
frmProd.Controls.Add lblDBDetails
frmProd.Controls.Add lblUID
frmProd.Controls.Add txtUID
frmProd.Controls.Add lblPWD
frmProd.Controls.Add txtPWD
frmProd.Controls.Add btnSubmit
frmProd.CancelButton=btnSubmit
frmProd.Text = "This is a PROD RUN"

frmProd.Height = 250
frmProd.Width = 350
frmProd.ShowDialog
DotnetUIDPWDForm = txtUID.Text & ":" & txtPWD.Text

Set frmProd=Nothing
Set lblDBDetails=Nothing
Set lblUID=Nothing
Set txtUID=Nothing
Set lblPWD=Nothing
Set txtPWD=Nothing
Set btnSubmit=Nothing
Set oPoint=Nothing
End Function


-Pankaj Dhapola 
Let's Think on it