Ask a Question

Property Wait to avoid Window destroyed error on Activate

SOLVED
colsson
Occasional Contributor

Property Wait to avoid Window destroyed error on Activate

Which property and property value should waited for before calling Activate on an object to avoid the error: "The window was destroyed during method execution".

 

 

Kind Regards

colsson

18 REPLIES 18
tristaanogre
Esteemed Contributor

Not really a property for checking that... basically, if the object is found, it can be activated.  The problem you're having is that the object is found then, between when it is found and when the Activate is called, something is destroying the object in memory and recreating it.  Perhaps try removing the "Refresh" function?  Not sure if that's going to cause that kind of process. 

 

FindChildEx might be a newer function.  If you're running TC 9, it's possible that it is not available in that version.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
colsson
Occasional Contributor

  • "The object is found" is that equivalent to object.Exists = True?
  • I have removed the "Refresh"

 

Kind Regards

colsson

tristaanogre
Esteemed Contributor

Yes... if the FindChild method returns the object... or if WaitChild returns the object after the time out, the object that is returned will have the "Exists" property set to true.

 

Does it work better without the Refresh?


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
colsson
Occasional Contributor

  • It does not work better without the Refresh, the infrequent error (The window was destroyed during method execution) occurred again on the new version of the test which does not have Refresh and has an Exists check.

If this problem is ever solved then I'll get a nice "aaaah" feeling Smiley Very Happy.

tristaanogre
Esteemed Contributor

Then we're back to trying to figure out what is destroying and recreating the object or determining from some other indicators in other objects of the application as to when things are done "processing" before you move on to the object activation.  For that... I'm sorry, not being there, I can't necessarily help with that.  This is going to take some Sherlock Holmes work on your part, observation, trial and error, etc. Sorry. 😞


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
colsson
Occasional Contributor

Thanks!

At least I know that there's (probably) not an easy solution that I'm missing.

tristaanogre
Esteemed Contributor

A possibility just occurred to me...  could there be more than one object that matches the criteria you're using in your "FindChild" method?  FindChild will find the first one and stop... so, if your search criteria is not specific enough, it could be that you're finding an object which is not the one you want and then, when the one you want appears, it destroys the other one?


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
colsson
Occasional Contributor

This application is started and terminated several times in the test therefor it's possible but not certain that this is the cause Smiley Happy

tristaanogre
Esteemed Contributor

Actually, that could very well be the cause...  if you're closing the application and opening it rapidly, is it possible that there are two copies of your application present in memory for a brief time, especially if it takes some time for your app to complete the close process?  So... what could be happening is that you're actually grabbing the object from the application that is in the process of shutting down....

 

Try something like this to close your application this will wait until the myApp process is unloaded before running it again.

 

myApp.Close(); //Don't know if this is the exact command you're using
while (Sys.WaitProcess('myApp', 1000).Exists) {
    Utils.Delay(1000);
}
myApp.Run()

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
cancel
Showing results for 
Search instead for 
Did you mean: