Childobjects:
Returns the collection of child objects contained within the object.
F1 Help explanation: Returns all child objects of the current calling object
This explanation is very abstract, below us a scenario, such as Page object, a page has 100 button buttons need to click, such as one of us to click, the code will need 100 lines, and requirements change, may increase to 200 button, Then we need to add 100 click Code lines, so the efficiency is very low, then there is no better application method, the answer is yes
Let's look at a piece of code first
Set odesc=description. Create ()
Odesc ("Micclass"). Value = "Webbutton"
Set buttons=browser ("Micclass:=browser"). Page ("Micclass:=page"). Childobjects (ODESC)
Nunberofbuttons=buttons.count
For i = 0 to NuberOfButtons-1
printf buttons (i). Value
Next
You can see what's not there, yes. All button clicks on a Web page are done using a descriptive programming +childobjects method
QTP childobjects Usage