Ask a Question

why is the findallchildren method not working?

newtotc
Occasional Contributor

why is the findallchildren method not working?

Public Function advancefindObject ()

Dim reqobj

propnames = "ObjectIdentifier"

propvalues = "leftnav"

depth = 20

Browsers.Item("iexplore").Run("http://www.google.com/#hl=en&output=search&sclient=psy-ab&q=test&oq=test&gs_l=hp.3..0l4.673.1032.0.1...")

Set objContext = Sys.Browser("iexplore").Page("")

reqobj = objContext.FindALLChildren(propNames,propValues,depth)

  for i = 1 to depth       

    If i < depth and reqObj.exists then

      log.Message "searched object is found at iteration:"&i

      'log.Message (reqobj.contenttext)

      If UBound(reqobj) >= 0 Then

            For j = 0 To UBound(buttons)

              Log.Message(reqobj(j).FullName)

            Next

            Log.Message("Total number of found enabled buttons: " & (UBound(reqobj) + 1))

        Else

              Log.Warning("No enabled buttons were found.")

        End If


     

      exit for

    else

      aqutils.Delay 6000

      log.Message i

      Set reqObj = objContext.FindAllChildren(propNames,propValues,depth)

   end if

    If i = depth then

      log.Message "Searched Object is not found even after 1 min"

    End if

  Next

end Function

3 REPLIES 3
HKosova
SmartBear Alumni (Retired)

Hello,



There're several errors in your script:



1) Page("") should be Page("*"). Empty string isn't a valid parameter for Page().



2) This line is incorrect:



The FindAllChildren method returns an array rather than a single object, so it doesn't have the Exists property.

I guess you meant the following:





3) UBound(buttons) in the innermost For loop should be UBound(reqobj).

Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
newtotc
Occasional Contributor

Hi Helen



Thank you for the reply.

yes I did see those errors yesterday and changed them 

But I still cannot figure out to capture the array of objects returned..

can u please give me syntax for this statement...



    reqobj = objContext.FindALLChildren(propNames,propValues,depth)



THanks for ur support



Thanks

AN



HKosova
SmartBear Alumni (Retired)

Hi,



Please see the examples at the end of the FindAllChildren Method article.

Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: