My question is: how can QARun close all windows on the screen if it is due to an error not clear by the end of the script which windows are still open?
I mean is ther a possibility for QARun to focus on a window, attach to the window, recognize it and close?
I hope I made it clear enough. Thank you for your help.
Sounds like you need to use the "On error call FunctionName".
When ever an error happens, like not being able to attach to a window, the error handler will call "FunctionName" instead of popping up a message telling you about it.
On error call MyErrorFunction
//do your test
//This routine will trigger when ever there
//is and error. It will stop the script and
logcomment ("Err = " + Err)
logcomment ("ErrFile = " + ErrFile)
logcomment ("ErrFunc = " + ErrFunc)
logcomment ("ErrLine = " + ErrLine)
logcomment ("ErrMsg = " + ErrMsg)
"If your not part of the solution, there's good money to be made in prolonging the problem."
If your not part of the solution, there's good money to be made in prolonging the problem.
It should solve my problem.
I am going on vacation next week.
As soon as I come back I am going to incorporate it in my script.
Thank you for your help.
By the way, do you have any idea why the script would fail this way.
If I run it during day it always recognizes the windows.
Only when script runs unattended such problem occur. And not every time.
Bugman, thank you for your reply.
Your answer does not exactly solves my problem.
Closing Popup windows is not my problem. I am catching them with if statement.
Several of my scripts run every night with the help of a scheduler (we don't have QADirector)
Once in a while with no apparent reason QARun does not recognize one window or another, produces a message " Can't attach to the window...". And those windows are still on a screen when I come to work next day.
This inability to attach is unpedictable.
I thought that if I could make QARun focus on a window first then recognize and then close it, it would solve my problem and the scripts that have to run after will be executed.
I was not able to do this yet.
QAGuy's log commenting should help you narrow down why the problem is occuring. You may also want to include a portion in your error handling function that performs a screen scrape and possibly some text capturing to try and determine if there is some difference in your application at the time when the error occurs.
As QARun can get confused by "stray" windows, we close all open windows at the start on a script/suite. We do the same upon a fatal error. Below is sample code.
TopWindowName = Topwindow("ignoretopmost") ;option to ignore the taskbar and report the top-most application window.
IsQADIRECTOR = FindStr(TopWindowName, "QADIRECTOR.EXE") ;So we do not close QADirector
IsQARUNEXE = FindStr(TopWindowName, "QARUNRUN.EXE");So we do not close QARun.exe
IsQARUNAWL = FindStr(TopWindowName, "RUNAWL.EXE");So we do not close Runawl.exe
If IsQARUNEXE > 0 OR IsQARUNAWL > 0 OR IsQADIRECTOR > 0
QAWindowCounter = 1 + QAWindowCounter
if IsQARUNEXE = 0
LogComment("FoundQARunCount = " + FoundQARunCount)
QAWindowCounter = QAWindowCounter - 1
LogComment("QAWindowCounter = " + QAWindowCounter)
until QAWindowCounter = 2