Forum Discussion

sameerjade's avatar
sameerjade
Frequent Contributor
7 years ago

"Object does not exist" without the error with WaitQtObject

Hello,

 

I am trying to check if a Qt Object exists and give a warning if not found. I do not want an error in my test report if object is not found. I am using the WaitQtObject. However I am not able to avoid the "object does not exist" error using a timeout value.

I know that this works with WaitWindow method but does not seem to work for WaitQtObject method.

 

var checkBox = Aliases.MyApplicationName.Settings.WaitQtObject("abc", 2000);

 

I get the error:

The object "QtObject("abc")" does not exist. 

 

Any suggestions are appreciated. Thank you!

 

I found some threads on similar topics but they are not Qt related:

https://community.smartbear.com/t5/TestComplete-General-Discussions/quot-Object-does-not-exist-quot-without-the-error/td-p/46502

https://community.smartbear.com/t5/TestComplete-Functional-Web/TestComplete-s-Exists-Function/m-p/63820#M4541

12 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Is there a direct child object under Aliases.MyApplicationName.Settings that is "QtObject("abc")"?  If there is not, then the error you get is correct.  Note that the "WaitQtObject" assumes that the object you're waiting fir is a DIRECT child of the parent object (in your case, Settings).  If there are any other objects in the tree between Settings and QtObject("abc"), you'll get that error.

     

     

     

     

    • sameerjade's avatar
      sameerjade
      Frequent Contributor

      Hi Robert,

       

      You are correct, "QtObject("abc")" is not a direct child of "Aliases.MyApplicationName.Settings". It is more like this: 

      var checkBox = Aliases.MyApplicationName.Settings.QtObject("firstChild").QtObject("secondChild").QtObject("thirdChild").WaitQtObject("abc", 2000);

       

      I also tried it this way but it still gives me "object does not exist" error.

      var parent = Aliases.MyApplicationName.Settings.QtObject("firstChild").QtObject("secondChild").QtObject("thirdChild");

      var checkBox = parent.WaitQtObject("abc", 2000);

       

      Thanks.

    • sameerjade's avatar
      sameerjade
      Frequent Contributor

      Is there any workaround to this situation? When I am trying to use WaitQtObject method on an object which is not a direct child of the main parent. By main parent I mean "Sys.Process('MyApp')" 

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Is there a reason why you haven't mapped the checkbox and given it an Alias?  That would be the ultimate solution... this would "collapse" your tree so you wouldn't have to worry about the different layers if they aren't necessary.  Then you can use WaitAliasChild to wait for the checkbox directly.

         

        Keep in mind, on your original problem, all the PARENT objects need to exist as well before you can call the WaitQTObject that you've indicated... so, if firstChild, secondChild, or thirdChild don't exist in time, you'll get the error as well.

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    var checkBox = Aliases.MyApplicationName.Settings.WaitQtObject("abc", 2000);

    When you get such error in JScript (maybe, in JavaScript as well), this usually means that the parent object was not found. And the text of the error is caused by the JScript language specifics (not related to TestComplete).

     

    I would suggest to change the quoted line of code to

    var checkBox = Aliases.MyApplicationName.WaitAliasChild('Settings', 30000).WaitQtObject("abc", 2000);

    and check if it helps.

    • sameerjade's avatar
      sameerjade
      Frequent Contributor

      Thanks Alex. When I try the way you suggested, I get this error:

      The object "AliasChild("thirdChild")" does not exist. 

       

      I changed "QtObject" to "WaitAliasChild". I think that Qt objects cannot use WaitAliasChild method ?

       

       

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi,

         

        > I think that Qt objects cannot use WaitAliasChild method ?

        .WaitAliasChild() method exists only for the objects that are NameMapped. As the thirdChild object is not NameMapped but is just a child of the Settings object that is NameMapped, you should use .WaitAliasChild() method to wait for the Namemapped object and .WaitQtObject to wait for the regular Qt child. Like it was in my example.