Close then Reopen Tested App
This is my first post so take it easy!
I have a testedapp which works great, I have a function created which sets the (simple) params then runs it, logins in etc.
We have a process where when we license the module, we have to close then reopen the application in order for it to be usable, so I would like to close my testedapp by closing the window (as if hitting the x) then rerun my function that launches the tested app again.
However, no matter what I try I cannot get it to execute the testedapp again; I have put a more than a reasonable delay in between the window close and the launch function; I have tried TestedApp.Close and TestedApp.Terminate - neither of which did anything. I have tried entering the entire code of the launch function as well as calling it as functionname()... I just can't figure this one out.
Any tips? I'm guessing something to do with the way testedapps work, I couldn't find a similar thread on here or elsewhere, and have read the Closing TestedApps page a few times now!
Thanks in advance
Solved! Go to Solution.
However, no matter what I try I cannot get it to execute the testedapp again; I have put a more than a reasonable delay in between the window close and the launch function; I have tried TestedApp.Close and TestedApp.Terminate - neither of which did anything.
It's not clear from this whether the problem is with closing or the second execution.
1) Try running the test in Debug mode and pausing it right before the close. Close the app manually and check Task Manager to make sure it's actually gone.
2) Reset and run the test in Debug mode again and step through the close but pause it right after that. Check Task Manager again.
3) If you can get through 1) and 2) and the app is gone from Task Manager, then leave the test paused and open the app for a second time manually to see if it will open.
Agree with @Marsha_R you must determine firstly if the tested app is still in memory or not after closing first time.
Some apps stay in memory because of dll, handles and so on. On these simple Terminate doesn't works, need to make termination from child to parent process (like Killing Process Tree in Process Explorer). You can also use the cmd TaskKill /T trick.
It could be related also to Windows apps cache management.
It could be related to the app itself, a bug .. have you tried different way of normal close (ALT F4, use of menu if it exists, sending WM_CLOSE message). I know some apps, and big ones, that doesn't do a proper close with the X button.
Speak a litt more on your test app, which kind of app is it ? what it does ?
Un sourire et ça repart
Thanks for the reply,
Yes, 1 and 2 are OK, nothing shows in Task Manager, part of the reasons I added an 8-sec delay in there to ensure it does close.
I can open the application manually no problem, the application supports multiple sessions, this is why I am so stumped on this, when I debug into the launch functions it gets through it fine, but on the TestedApp.Run it just doesnt Run!
Appreciate the response, thank you.
The app is our flagship ERP client, I know that after closing the main form (all others already closed at this point) it takes a few seconds to completely die in the background, but closing the form is sufficient to end all threads. The application supports multiple sessions so shouldn't be an issue with spinning up a new instance. I will play around with different close methods, that's not a bad shout, you never know!
Will also liaise with our product devs, I'm new to TestComplete and from a different team outside of product dev, so could well be specific to our app.
for reference I am doing:
Aliases.myApp.ShellMenuForm.Close(); aqUtils["Delay"](8000); ERPLogin();
where ERPLogin() does:
-Set Simple Params
-myApp.Run(1, true, 300)
I feel a bit stupid now, I didn't have the "Launch" method in the script, I had Run but not launch before it,
I found this out by trying to run my test end-to-end on the off-chance this would get past the issues I was hitting during the function by function testing... I had an error in my log about "set to false" a quick search on here and I found I needed Launch. I think it is working now!
Never feel stupid to find your own errors and improve yourself and furthermore with no hiding to others your own errors ;^)
Un sourire et ça repart