Forum Discussion

bo_roop's avatar
bo_roop
Contributor
7 years ago
Solved

Need C# syntax for ChildObjectName inside of a WaitChild event

The online help shows me this:

 

if (Obj["WaitChild"](ChildObjectName, 0)["Exists"])

 

What I want to do is use ["Panel"](2) as my child object's name... but I can't figure out the syntax to set ChildObjectName = ["Panel"](2) in my script and get it to replay without errors.

 

 

I also can't reliable use a FindChild event as TestComplete does not replay 100% of the time. :(

  • Try changing from FindChild to FindChildEx with an additional parameter for timeout (see my example above)

12 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Well, what errors are you getting, first of all, because that will help us know better what EXACTLY is going wrong.

     

    But suffice it to say, you need to Name as EXACTLY the string as it shows in Object Browser. So, if the string shwos as ["Panel"](2) then you need to present that as a string.

     

    So... I don't know C#Script well, but I'm assuming that the code should be something more like

     

    ChildObjectName = "[\"Panel\"](2)"

    Because the C# Script language base in TestComplete has it's root in JScript, you need the slash (\) characters before the double quotes to indicate that you are using the double quotes.

    • bo_roop's avatar
      bo_roop
      Contributor

      Sorry,

       

      Should have mentioned that that syntax doesn't work either. :(

       

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        So, what do you get in the way of errors, if any?

         

        Have you tried the following?

        ChildObjectName = "[\"Panel\"](2)"
        
        if (Obj["WaitChild"](ChildObjectName, 10000)["Exists"])

        According to the help documentation, (https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/common-for-all/waitchild-method.html), that second parameter, if it's set to 0, will return immediately... even if the object is not found.  By changing it to 10000, it actually sets a maximum time to wait for the object to appear.  It COULD be that the object may have a delay before it "Exists" and you need to actually wait for it.