Forum Discussion

finae's avatar
finae
Contributor
10 years ago

Getting all child's child's etc. object's property values

Hi,

 

I was testing to see if i can a complete list of properties/value for my desktop application , doing it manually would basically take .. along time so i thought creating a function that call itself, either implementation is incorrect but if someone can help with this it would be nice. 

 

 

count=0
function fractal(innerobj)
  'go through all child
  count=count+1
  
  log.Message "pass: " & count & ", childcount: " & innerObj.childCount 
  if innerObj.childcount>0 then
    for i=0 to childcount
        log.Message "innerobj name: " & innerobj.NativeCLRObject.Name
      set childObj=innerObj.Child(i) 
      call fractal(ChildObj)
    next
  else
    log.Message innerobj.fullname
  end if
end function

the idea is to have the function call itself, with each pass sending the child of the object to itself.

 

I thought this would go through the loop of each child and its child and its child until it reaches the end and then loop backward and go to the nxt child.

 

It seems that once it hit the last child of the first tree, it stop the excecution.

  • You need to keep track of childObj so you can go back to the next one when you've been down one tree.  You're resetting it every time so by the time you get to the end of the first tree, you have no where else to go.

     

    Just curious, what will this list be used for?

  • You need to keep track of childObj so you can go back to the next one when you've been down one tree.  You're resetting it every time so by the time you get to the end of the first tree, you have no where else to go.

     

    Just curious, what will this list be used for?

    • finae's avatar
      finae
      Contributor

      The list make devloping script extension to TC of our products alot easier.

      I've only started with one portion of the product but notice that i've run across alot of the re-mapping to get the name/caption  of the object thats visible on screen , this way i can use use"Find/FindChild", to locate the object and interact with it.

       

      an example:

       

      the TC extension i have created is a new sub-section of the Keyword Operation.

      within this section i have items like:

       

      Dialog - Confirm :

      Grid - Context Menu

      Tab - Select

      Tab  - tabName - Toolbar

      Primary Toolbar

      etc.

       

      so when i create a new keyword operation test, i would drag the primar toobar item to the test

      and it would allow me to select which button in the toolbar i want to click on

      then if i m expeting input etc, i can drag those in and fill in the input

      and so forth

      once done

      i can drag the primary toolbar and select 'save' to save the entry 

       

      when this is run it will click on teh button, does data input, etc. and click save at the end. With this way, i can create multiple scenarios without having to code or recall script functions for new items.

      I can just drag the operation i have created into the keyword test and select what i want it to do and in what order.

       

       

       

       

       

       

       

      • finae's avatar
        finae
        Contributor

        ive found a solution using : 

        set childobjs =CreateObject("System.Collection.ArrayList")

         

         

        class objtest
          public objList
          public name 
          private sub Class_Initialize
            set objList=CreateObject("System.Collections.ArrayList")
          end sub
        end class
        
        
        function fractal(innerobj,parent)
          'go through all child
          count=count+1
          VisChilds = innerobj.FindAllChildren("visible","true",1)
          if ubound(vischilds)<0 then
            if innerobj.Name <>"" then 
              log.Message "parent: " & parent.name & ", This Object: " & innerobj.Name
            else
              log.Message innerobj.FullName
            end if
              
          else
            set childObj = new Objtest
            childobj.name = innerobj.fullname
            for i =  0 to ubound(visChilds)
              childObj.objList.Add visChilds(i)
            next
            for i=0 to childobj.objList.count-1
              fractal childobj.ObjList.item(i),innerobj
            next
          end if  
        end function
        sub Test
             set obj = sys.process("applicationInstanceName")
             fractal obj, obj
             log.message count
        end sub

        At this same time, i can also look for objects that are in the background and not visible, but this is basically give me what i need to do the coding i need to do. The only catch of course is that it has to be on screen which isnt a problem as i need it to be onscreen anyway.

         

        if there's any other suggestion i would be more than happy to read through and try or if there's suggestion on a better way of doing it. (i dont need the class i m sure and just create the object arraylist in the function and it should still create a space in memory for the list to loop through.