Forum Discussion

ArmandsBruns's avatar
ArmandsBruns
Frequent Contributor
12 years ago

FindAllChildren Method

Hi,



Maybe someone knows

 



I have a function to find the last value("Correct") in list and click on it.

But how can I search a value("Correct") the one before the last value("Correct") in list and click on it?

---------------------------

Function SearchPropValue(Location )

 

  Dim SearchObject



  propArray=Array("innerText")

  propValue=Array("Correct")

  SearchObject = Location.FindAllChildren(propArray,propValue,20000,True)

  If UBound(SearchObject)>=0 Then

  i=0

    For i = UBound(SearchObject) to LBound(SearchObject) Step - 1

      SearchObject(i).Click

    Next

      Else

      Log.message("Not find - Correct")

  End if

   

End Function

-------------------------



BR

Armands

4 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Armands,



    You can do this using XPath (Page.EvaluateXPath):

    Dim arr, SearchObject

    Set page = ...



    arr = page.EvaluateXPath("(//*[text()='Correct'])[last()-1]")

    If UBound(arr) >= 0 Then

      Set SearchObject = arr(0)

      SearchObject.Click

    Else

      Log.Error("The object with the ""Correct"" text was not found.")

    End If
  • Hi Everyone,



    I am trying to get all the Child objects but not working.



    Sys.Process("ACD").VBObject("fcash").VBObject("img_8")



    The Name of VBObject("fcash") change dynamically like fcash_2,fcash_3,. So I need to get the name of the VBObject. Below is my code, but not working. Can any one help me???



    Code:



    Function PanelObj()

     PropArray=Array("ACD","Enabled")

    PropValue=Array("fcas*",True)



    panel= Sys.Process("ACD").FindAllChildren(PropArray,ValueArray, 2000)



    If UBound(panel) >=0 Then

     

     For i=0 to UBound(panel)

      Log.Message (panel(i).Name)

     Next

    End IF



    End Function



    Please help!!!



  • ArmandsBruns's avatar
    ArmandsBruns
    Frequent Contributor
    Hi Anand Kumar Meher,



    Try this:

    ====================

    Function FindChild(location, typeID, name, pressed_object)

     

      Dim Attr, counter

      Set Attr = Log.CreateNewAttributes

      Set Attr2 = Log.CreateNewAttributes  

      Attr2.Bold = True

      Attr2.FontColor=RGB(255, 0, 0)  

     

      FindChild = False

     

      Sys.Refresh()

      Aliases.RefreshMappingInfo

     

      counter = 0

     

      Do

        counter = counter + 1



          Sys.Refresh()

          Aliases.RefreshMappingInfo

          

        If(location.FindChild( typeID, name,30).Exists <> Empty ) Then

          FindChild = True

          log.Message("Find the - '"+typeID+"', '"+name+"'.")

          

          object = location.FindAllChildren(typeID, name, 20000, True)



          For i = 0 to UBound(object)

            If object(i).Exists and object(i).Visible=True Then

              log.Message "Pressed the - '"+pressed_object+"'",,, Attr

              object(i).Click)

            End If

          Next

       

          Log.Message "Find: " & (UBound(objekts) + 1)

        Else

          Aliases.RefreshMappingInfo

          aqUtils.Delay(1500)

          Sys.Refresh()

          Aliases.RefreshMappingInfo    

          log.Message ("Didn't find: '"+typeID+"', '"+name+"', '"+VarToStr(counter)+" - attempt!'")

        End If



      Loop Until FindChild = True or counter > 24

     

        If counter = 25 and FindChild = False Then

          Log.Error "Didn't press the: '"+pressed_object+"'",,, Attr2

        Else

          Sys.Refresh()

          Aliases.RefreshMappingInfo  

        End If



    End Function

    =================



    Best regards

    Armands