Forum Discussion

vthomeschoolmom's avatar
vthomeschoolmom
Super Contributor
14 years ago

objects just aren't there anymore

I am writing test scripts for a VB 6 app. There are bits of my TestComplete scripts that work great... until they just don't anymore. For instance, when the tested app is loaded, the very first thing that is displayed is a logon form. 9 times out of 10, TestComplete clicks the logon button. (In case it is important, this is actually a custom control that is a button within a picture box.) Every once in a while TestComplete will get to that line of code and fail to find the control to click.



This happens intermittently also with a treeview I am using. TestComplete will find the right node a bunch of time. I will run the script another time, and seemingly randomly, the treeview will not be found. When I look in the object browser, I can see the object. I have not made any changes to the mapped names.



What could be happening here, please?



Thanks



L


  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    This sounds like the "classic" timing errors in which the script code executes a lot faster than the application under test can keep up.



    I would highly recommend researching and getting familiar with the various "Wait" methods such as WaitChild, WaitVBObject, WaitAliasChild, etc.



    There's an excellent help topic on this as well at 



    http://smartbear.com/support/viewarticle/12168/
  • I am familiar with timing issues. I do not believe that is the issue. First I AM waiting for the object to be created. I can SEE the object at the point TestComplete is failing.
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Could you toss up here a snippet of the code you're running and/or screen shots of the object browser, name mapping scheme, etc, perhaps, especially, a set of screen shots showing the state of your application and the object browser when the problem occurs so we can figure out why the objects aren't being found.
  • Is there a private support area I can do that to? I am not permitted to put up screen shots of our product. Thanks



    L
  • Hi Lane,



    If the problem cannot be reproduced stably, you can try the steps below:



    1. Insert the following routine call before retrieving the problematic object in your test (change the process name):




    LogAppStructure(Sys.Process("MyProcessName")) // or  LogAppStructure(Aliases.MyProcess))






    Here is the LogAppStructure routine code:




    ' VBScript



    Sub LogAppStructure(obj)


      Err.Clear


      On Error Resume Next






      Dim count, i, Str


      


      ReDim params(7) 


      params(0) = "WndClass"


      params(1) = "WndCaption"


      params(2) = "Index"


      params(3) = "Visible"


      params(4) = "Exists"


      params(5) = "ClrFullClassName"


      params(6) = "ProductName"


      params(7) = "ProductVersion"  


      


      Str = ""


      For i = 0 To UBound(params)


        If IsSupported(obj, params(i)) Then


          Str = Str & params(i) & " = " & VarToStr(Eval("obj." & params(i))) & VbCrLf


        End If


      Next


      


      Call Log.AppendFolder(obj.Name, Str)


      For i = 0 To obj.ChildCount - 1


        Call LogAppStructure(obj.Child(i))


      Next


      Log.PopLogFolder






      On Error GoTo 0


    End Sub







    // JScript, C#Script



    function LogAppStructure(obj)


    {


      var count, i, Str;


      


      var params = new Array();


      params.push("WndClass");


      params.push("WndCaption");


      params.push("Index");


      params.push("VisibleOnScreen");


      params.push("Exists");


      params.push("Visible");


      params.push("FullName");


      params.push("ClrFullClassName");


      


      Str = "";


      for (var i = 0; i < params.length; i++) {


        if (IsSupported(obj, params))


          Str += params + " = " + VarToStr(eval("obj." + params)) + "\r\n";


      }


      


      Log.AppendFolder(obj.Name, Str);


      for (var i = 0; i < obj.ChildCount; i++) {


        LogAppStructure(obj.Child(i));


      }


      Log.PopLogFolder();


    }






    2. Execute your test and reproduce the "Object not found" problem. The LogAppStructure function will post the entire structure of the tested application to the test log and you will be able to see how objects are recognized right before the problem occurs.


    3. If you fail to find the cause of the problem using the test log, zip your entire TestComplete project suite folder along with the log of the test execution and send me the archive via our Contact Support form. Make sure that messages in your log correspond to correct actions in the latest version of your test.