Forum Discussion

geethwind's avatar
geethwind
Contributor
14 years ago

using FindChild() method on Id property

i am facing an issue with the below code



main()

  test("button","122")



function test(strtype,strID)

   PropArray = Array("id")


   ValuesArray = Array(""& strID& "")

   

   set testobj = pg.FindChild(PropArray ,ValuesArray ,100,True)

   if testobj.exists then

        testobj.click

  end if



end function





the issue is, i am passing the hardcoded ID value thinking it is always the same for that button on page, but looks like everytime ths ID value is changing for that button...so its clicking a different object with that ID..



i want a generic function, which can handle any type of object comes in and perform the corresponding aciton based on the type of it.



is it a right way to take ID property here or do i need to check any other property like Name/Caption....etc??



Thanks,






1 Reply

  • Hi,


    If the ID property is dynamic, do not use it. Try to search for the button by other properties. For example, you can use the WndClass or WndCaption property. If you search for objects on web pages, you can verify the tagName property value.