Forum Discussion

rlent's avatar
rlent
Contributor
15 years ago

Incorrect object names

I have an application where I am expecting to see this:   Sys.Process("XXXX").XXXXMainForm.WinFormsObject("ribbon")



But instead, the object is this: Sys.Process("XXXX").Window("WindowsForms10.Window.8.app.0.3ce0bb8", "XXXX", 1).WinFormsObject("ribbon")



Sometimes, I can Test Complete to know the correct name of the object, although when this happens, I can't figure out what I did to make it work. Obviously, it's mangling the automated testing. I am using Test Complete 7.5.2. Has anyone else seen anything like this, and does anyone have any idea what to do about it?

3 Replies

  • Hello Robert,


    The problem is caused by the fact that your application is not recognized as Open. Try increasing the "Open Applications | General | Method invoke timeout" project setting (set its value to more than 20000 ms) and see whether this solves the problem. To learn more about the options, see the "Project Properties - General Open Applications Options" help topic.


    If this does not help, I can suggest that you try the following workaround script. This script waits until the main form object ('MainForm') gets a valid 'WinFormsObject' name and returns this object.


    [VBScript]

    Function getMainForm()

      ' The default timeout is 60 seconds

      timeout = 60000


      Set proc = Sys.Process(<ProcessName>)

      Set mainForm = Utils.CreateStubObject

      oldTimeout = Options.OpenApps.InvokeTimeout

      endTime = GetTickCount + timeout

     

      Do While GetTickCount < endTime

        Set mainForm = proc.WaitWinFormsObject("MainForm", 0)

        If mainForm.Exists Then

          Exit Do

        End If

        Delay 200

        ' This line resets the object tree

        Options.OpenApps.InvokeTimeout = Options.OpenApps.InvokeTimeout + 1

      Loop

      Options.OpenApps.InvokeTimeout = oldTimeout


      If mainForm.Exists = False Then

        Log.Warning "Unable to get the main form object."

      End If

       

      Set getMainForm = mainForm

    End Function


  • Thanks, that worked. I'm testing within a VM, so it's a bit slow. Perhaps the default setting for this should be increased? It wouldn't affect most people's usage, and would help it work better on slower systems.
  • Hello Robert,


     


    I suppose that it takes much time to load the tested
    application completely as some complex actions are performed in the
    application's GUI threads when the application is started. You can set the
    value of the "Method invoke timeout" option to 60000 ms instead of
    using the script, but this will not make your test to get the main form object
    faster and can lead to some performance problems with other tests.