Forum Discussion

aceishigh's avatar
aceishigh
Contributor
14 years ago

Is There A Wait Method for FindChild?

Hi,

I use the FindChild method to search a web page and return the object if it exists. My code to do this is as follows. I'm wondering if I could use a native Wait method instead of the code I have to wait for the object to exist? Could I make use of WaitChild maybe?

Any idea would be welcome.

Thanks,

John




Public Function GetObjectbyID(idStrName,pg)

Dim iLoop,PropArray,objTemp



 



Log.Message "Starting the GetObjectbyID function"

PropArray = Array("idStr")

ValuesArray = Array(""&idStrName&"")

Set objTemp = pg.FindChild(PropArray,ValuesArray,100,True)

iLoop = 0

Do While NOT(objTemp.Exists) AND iLoop < 10

    aqUtils.Delay 1000

    Log.Message "GetObjectbyID: Object not found on attempt " & iLoop

    Set objTemp = pg.FindChild(PropArray,ValuesArray,100,True)

    iLoop = iLoop + 1

Loop

If objTemp.Exists Then

    Log.Message "GetObjectbyID: Object returned with ID:" & idStrName

    Set GetObjectbyID = objTemp

Else

    Log.Error "GetObjectbyID: Object not found with ID:" & idStrName

    Set GetObjectbyID = nothing

End If

'Destroy objects

Set objtemp = nothing

End Function

 



2 Replies

  • Hi Jack,



    No, there's no built-in "wait" analog of FindChild. WaitChild is only for direct children and only uses the object names from the Object Browser. So, your approach is the way to go.



    By the way, there's no need to use arrays when searching by a single property: