Forum Discussion

John-ITA's avatar
John-ITA
Occasional Contributor
13 years ago

Can I make TestComplete not log an error?

I'm using this line of code "Set TempObj = TempObj.WaitChild(NamesArr(i),10)" to get an object to test with and I know sometimes it isn't going to exist so I would like to stop TestComplete from logging "The object does not exist. See Additional Information for details.  You are trying to call the "WaitChild" method or property of an object that does not exist."  I have code in place to check when to report a missing object error based on what I'm testing.  Does anyone know if I can turn off this error?



John

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    not really.  What you need to do is actually use a WaitChild or something to assign your test object in the first place.  So, you would have



    var TestObj = sys.Process('MyApp').WaitChild('MyObject', 10000)

    if TestObj.Exists then

    var newObj = TestObj.WaitChild()




    It's a matter of making sure that you check for the object before you try and use it... and if you're not sure it will exist, you need to first use a Wait or Find method to find it.  Those methods return a "stub" object with Exists = false if the object returns empty.  No other properties are included so you can't test for things like Visible or call methods like WaitChild if Exists = false.
  • John-ITA's avatar
    John-ITA
    Occasional Contributor
    Thanks.  If you saw my full function you would see that my code and yours are doing the same thing, except I'm looping through an array of objects starting at the page level down through the final control on the page.  Your comment about "can't don't waitchild if the object doesn't exist" made me realize that in my case I'm getting to an object like SELECT and there are none on the page.  Therefore when I try to do SELECT.waitchild(cmbStates,100) I'm getting my error.  So I need to put a check for exists in my loop and as soon as I hit a false I need to exit my loop.



    Thanks again.

    JJ