Micro Focus QTP (UFT) Forums
Childobject of a window - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Childobject of a window (/Thread-Childobject-of-a-window)



Childobject of a window - soumyas - 11-22-2010

Hi,

I am using the following code to highlight & name the childobjects of "calculator" (calc)in windows:

Code:
Set DescObj=Description.Create

Window("Calculator").Activate
Set childObject=Window("Calculator").Childobjects(DescObj)
msgbox childObject.count

For i=0 to childObject.count-1
    childObject(i).highlight
    msgbox childObject(i).GetROProperty("Class Name")
Next


Thought the count of the childobjects is 31, for the last iteration the following error is displayed:

Code:
General run error.
Line (10): "childObject(i).highlight".


I have used the above code on other windows application like windows address book (wab). the result is the same.

However if I use a similar code on a Dialog box, there is no error displayed. Ex: Flight reservation dialog box

Code:
Set DescObj=Description.Create

Dialog("Login").Activate
Set childObject=Dialog("Login").Childobjects(DescObj)
msgbox childObject.count

For i=0 to childObject.count-1
    childObject(i).highlight
    msgbox childObject(i).GetROProperty("Class Name")
Next


Please let me know as why is this happening.

Thanks,
Soumya


RE: Childobject of a window - cbeggs - 11-22-2010

I tried this myself but I wasn't able to record my test so I used Descriptive Programming and it worked.
Code:
Dim desCalc
Set DescObj=Description.Create

Set desCalc = Description.Create()
desCalc("title").value = "Calculator"
Window(desCalc).Activate
Set childObject=Window(desCalc).Childobjects(DescObj)
msgbox childObject.count

For i=0 to childObject.count-1
childObject(i).highlight
msgbox childObject(i).GetROProperty("Class Name")
Next

To get the number code of the General Run Error you are getting, try inserting
Code:
msgbox Err.Number
after the line where error occurred.


RE: Childobject of a window - soumyas - 11-23-2010

I am getting this error evein with descriptive programming..
I am using QTP 9.5 (if this info helps!)
Somebody plz help!

Cheers,
Soumya


RE: Childobject of a window - cdesserich - 11-24-2010

I don't think all objects support the Highlight function. Child object number 31 must be one of those?


RE: Childobject of a window - Anu123 - 11-24-2010

I did try above code, error thrown after 29th object heighlight.
And error thrown for existance of the object also


RE: Childobject of a window - manishbhalshankar - 11-30-2010

What object is it?
Check if that object supports Heighlight method.