Forum Discussion

whuang's avatar
whuang
Regular Contributor
6 years ago

Keep getting Object required error message when using FindAllChildren method

Hi everyone,

I was trying to use FindAllChildren method to look for an object from the parent, but I keep getting "VBScript runtime error. Object required: 'FindAllChildren(...)'" when I run the script below. But if I use Find or FindChild method, it worked fine. Can anyone help me what was wrong?

 

Sub test

sys.Browser("*").Page("*").Find("contentText", "CorelDRAW Graphics Suite 2019 Education Edition", 10).Parent.FindAllChildren("ObjectLabel", "Choose a language:", 50).ClickItem("Spanish")

End Sub

 

Thanks!

  • Hi whuang 

     

    Why are you combining FindAllChildren with a click ?  FindAllChildren returns an array of items, not a single item, even if the array has a length of 1.  TC probably won't know what to click.  Since FindAllChildren excudes the current node, it is possible that by doing a FindAllChildren, you are excluding the one thing that TC can click, namely the parent.  If you use a FindChild rather than FindAllChildren with exact riterai, you should get a single list to to clickitem on

     

     

  • Hi whuang 

     

    Why are you combining FindAllChildren with a click ?  FindAllChildren returns an array of items, not a single item, even if the array has a length of 1.  TC probably won't know what to click.  Since FindAllChildren excudes the current node, it is possible that by doing a FindAllChildren, you are excluding the one thing that TC can click, namely the parent.  If you use a FindChild rather than FindAllChildren with exact riterai, you should get a single list to to clickitem on

     

     

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      To add to RUDOLF_BOTHMA 

      You're combining a Find to find an object and then calling the parent of it before doing a findallchildren... what if the first Find doesn't find anything at all?  Or, what if the first find finds something that doesn't HAVE a Parent to call "FindAllChildren" on?

      If you're going to use Find methods to find objects, you need to add additional code to verify that the Find worked all along the line.  Otherwise, you'll get all sorts of potential object not found issues.

      • whuang's avatar
        whuang
        Regular Contributor

         Thanks tristaanogre RUDOLF_BOTHMA I thought FindChild method would only search for one child and return the search result, and FindAllChildren would look through all Children but still return the first finding as the result. Now I understand. Below is the screenshot of the tree view. Link(0) is the object I was looking for by using the first Find, and the LanguageSelection is somewhere under another parallel object. Can you let me know whatelse I can add into the code to the Find worked all along the line?