Quick test professional

QTP Tips QTP codes QTP Faqs and more

Get Each Radio in RadioGroup And Check

Get Each Radio in RadioGroup

And Check

Set opt=Description.Create
opt(“html tag”).value=”INPUT”
opt(“type”).value = “radio”
Dim allOptions,all
Set allOptions=Browser(“a”).Page(“b”).Frame(“c”).ChildObjects(opt)
all=allOptions.count
MsgBox all

for i= 0 to all
eName=allOptions(i).getROProperty(“name”)
noofradio=allOptions(i).getElementsByName(eName).length
for j= 0 to noofradio-1
radioname=allOptions(i).object.document.getElementsByName(eName).item(j).GetAdjucentText(“afterend”)allOptions(i).object.document.getElementsByName(eName).item(j).checked=true
msgbox radioname
next
next

  Source: Mercury Forum’s KB articles

Advertisements

February 14, 2008 - Posted by | Descriptive Programming and Child Objetcs | , , , , , , , ,

8 Comments »

  1. The above code is not work please tell me how can we use GetELementsByName in a better way

    Comment by Rajendra | March 31, 2008 | Reply

  2. It is workimg code only. what was the error you have got?

    Comment by quicktestprofessional | March 31, 2008 | Reply

    • Hi Mohan,

      I tried the same code but count always returns 1. Please help me.

      Comment by Anand | June 2, 2013 | Reply

  3. I got error saying object doesn’t support this property on this line noofradio=allOptions(i).getElementsByName(eName).length

    Pls give some more details

    Comment by hari Muddana | April 13, 2008 | Reply

  4. I got error object does not support getElementsByName property.
    pls comment futher detail and for me some solutions

    Comment by utdt | July 16, 2009 | Reply

  5. Use-set x=Browser(“My Page”).Page(“My Page”).WebRadioGroup(“group1”).Object.document.getElementsByTagName(“INPUT”)

    msgbox x.length

    For each radio1 in x

    msgbox radio1.type
    msgbox radio1.value

    Next

    Comment by Nir | March 15, 2010 | Reply

  6. Hi Mohan,
    I have encountered a problem…the problem is like in a Webtable thre are 9 cols and 3 rows.In the 9th column we have a checkbox.I have an some unique number in the 1st column of the Webtable..We also got the same unique Id from the previous step.So by comparing this unique Id with the one in the 1st column of the Webtable,i have to check the checkbox.The code i used is like

    sRowcnt = Browser(xx).Page(xx).Webtable(xx).Rowcount
    For i = 1 to sRowcnt
    srequestid = Browser(xx).Page(xx).Webtable(xx).GetCelldata(i,1)
    If Sreqid = srequestid Then
    Set sobj = Browser(xx).Page(xx).Webtable(xx).Childitem(i,9,”WebCheckBox”,0)
    sobj.Set “ON”
    Exit For
    End If
    Next

    This doesn’t worked for me…….I get the error like “sobj required”

    Can u pls help me out…….

    Comment by vasanth | March 31, 2010 | Reply

  7. This is my first time pay a quick visit at here andd i am actually
    happy to read all at single place.

    Comment by toeic æ-¥æœ¬ æ-¥ç¨‹ | September 30, 2014 | 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: