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?
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.
' 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)
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.
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.
-- Dmitry Nikolaev
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️