I want to check selected and not selected radio button
I am new to QTP and using QTP 8.2. There are two radio buttons in a web page and by default first one is selected. User can select any one of them. Now when user comes to this page first time, I want to check that first radio button is selected and second one is not selected. How can I do that? Thanks.
[B]Question asked by visitor Aakash[/b]
Re: I want to check selected and not selected radio button
i m alos facing same problem
Re: I want to check selected and not selected radio button
Hi there,
You have manipulate your test logic. below is example of how to select radio button - there are two radbut (1) Checking and (2) Saving
for i = 1 to 2
if i = 1 then
browser("b").Page("p").WebRadioGroup("rb").Select "check"
else
browser("b").Page("p").WebRadioGroup("rb").Select "saving"
End If
Next
Re: I want to check selected and not selected radio button
[QUOTE=;][/QUOTE]
When I'm using Radio Button, It is not working plz help me how to use it?
Re: I want to check selected and not selected radio button
you can use GetROProperty
intIndex = browser("b").Page("p").WebRadioGroup("rb").GetROProperty("selected item index"). This will return 1 or 2, in your case.
But if both the radio buttons are not checked it may return the default values index. So validate one more property "checked". If this property returns one then it means that one of the radio button is selected.
intChecked = browser("b").Page("p").WebRadioGroup("rb").GetROProperty("checked")
If intChecked is equal to 1 then proceed with your validation.
Re: I want to check selected and not selected radio button
[QUOTE=learqtptesting;45314]Hi there,
You have manipulate your test logic. below is example of how to select radio button - there are two radbut (1) Checking and (2) Saving
for i = 1 to 2
if i = 1 then
browser("b").Page("p").WebRadioGroup("rb").Select "check"
else
browser("b").Page("p").WebRadioGroup("rb").Select "saving"
End If
Next[/QUOTE]
in case of webradiogroup ?
Re: I want to check selected and not selected radio button
Hi friend,
If this is web radio group then use status ON and OFF.
Thanks,
Deepa
Re: I want to check selected and not selected radio button
This is for QTP10:
' Loops through swfRadioButton in a frame, gives name & if it is selected
' Windowname is the name of your window
' framename is the container in which the radio buttons are located
set container = SwfWindow("Windowname").SwfObject("framename")
Set Desc = Description.Create()
Set ChildObjects = container.ChildObjects(Desc)
cnt = ChildObjects.Count
If cnt > 0 Then
For i = 0 To cnt - 1
mybuttons = mybuttons &ChildObjects.Item(i).GetROProperty("name") & ": checked="& ChildObjects.Item(i).GetROProperty("checked") &VbCrLf
Next
Else
msgbox container.ToString() & " does not have any child objects."
End If
msgbox mybuttons
Set container = nothing
Set desc = nothing
Set chilobjects = nothing
cnt=""
mybuttons = ""
Re: I want to check selected and not selected radio button
Hi Akash...
Hope your problem is solved.
Else
1) You can use GetRoProperty and get the value of property "Value" form the webRadioGroup which you are referrring, the retrun value will contain the radio button which was selected. (If the webRadiogroup has a value for each radio button option)
2) You can use GetRoProperty and get the value of property "selected item index" form the webRadioGroup, the retrun value will contain index (Index starts from 1) of the selected radio buttion which was selected. (If the webRadiogroup doesn't have value for each radio button option)
hope this will help you.
Regards,
kumar