Forum Discussion

newtotc's avatar
newtotc
Occasional Contributor
12 years ago

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.1366.4.4.0.0.0.0.202.652.0j3j1.4.0...0.0...1c.7jJqdtQ6Sak&pbx=1&bav=on.2,or.r_gc.r_pw.r_qf.,cf.osb&fp=92012027ea7e328b&biw=1920&bih=936")

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

  • HKosova's avatar
    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).
  • newtotc's avatar
    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