Quick test professional

QTP Tips QTP codes QTP Faqs and more

Prompt Dialog with Radio buttons in QTP with help of DotNetFactory

The following code popup a dialog with 2 radi button to select an option when it run from the QTP

Set objForm = DotNetFactory.CreateInstance(“System.Windows.Forms.Form”, “System.Windows.Forms”)

Set objRd1 = DotNetFactory.CreateInstance(“System.Windows.Forms.RadioButton”, “System.Windows.Forms”)
Set objRd2 = DotNetFactory.CreateInstance(“System.Windows.Forms.RadioButton”, “System.Windows.Forms”)
Set objGb = DotNetFactory.CreateInstance(“System.Windows.Forms.GroupBox”, “System.Windows.Forms”)
Set objBtn2 = DotNetFactory.CreateInstance(“System.Windows.Forms.Button”, “System.Windows.Forms”)
x=10
y=10
Set p1 = DotNetFactory.CreateInstance(“System.Drawing.Point”,”System.Drawing”,x,y) ‘This will provide the locations(X,Y) for the controls

objRd1.Text=”Radio1″
objGb.Location=p1

p1.Y=30
objRd1.Location=p1
p1.Y=CInt(objRd1.Height)+CInt(objRd1.Top)+10
objRd2.Location=p1
objRd2.Text=”Radio2″
objGb.Text=”Select The Radio Button”
objGb.Controls.Add(objRd1)
objGb.Controls.Add(objRd2)
objBtn2.Text=”OK”
p1.X=60

p1.Y=CInt(objGb.Height)+20
objBtn2.Location=p1
objForm.CancelButton=objBtn2

objForm.Controls.Add(objGb)
objForm.Controls.Add(objBtn2)
objForm.StartPosition=CenterScreen
objForm.Text=”Mohan kakarla”
objForm.ShowDialog
If objRd1.Checked Then
msgbox “You have selected Radio 1”
elseif objRd2.Checked Then
msgbox “You have selected Radio 2”
else
msgbox “No Radio button was selected”
End If

Author: Mohan Kumar Kakarla

Advertisements

March 15, 2008 - Posted by | DotNetFactory, Uncategorized | , ,

6 Comments »

  1. Hi ,
    Iam Hari krishna
    I find your blog interesting and useful in QTP Execution.I request u to include my mail so that we can exchange ideas.

    Comment by Harikrishna | April 10, 2008 | Reply

  2. Hi Hari,
    your blogs on QTP are really useful.
    kindly add me in the list .

    Regds
    kavita Khadwal

    Comment by kavita | July 7, 2008 | Reply

  3. This is good but I’m having a related issue. I have an application with 2 radio buttons. Both have the value of “#0”. I’m using QTP 9.2, so what can I do to make QTP recognize when one radio button has been selected and when the other has been selected??? Any and all help would be greatly appreciated.

    Comment by Sqatester_Elite | October 17, 2008 | Reply

  4. Well done! This really helped.

    Keep up the good work. I want to see more posts from you.

    Comment by Srikanth Perath | January 7, 2010 | Reply

  5. Please advise as how can I change the backColor and backgroundImage of a form created using DotNetFactory.

    Thanks.

    Comment by Bitu Das | December 28, 2010 | Reply

  6. Hi…did u get a reply to the “#0” issue.I am facing the exact problem…all help would be appreciated.

    Comment by Arpita | January 4, 2011 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: