To successfully quit in a graceful manner, you may have to close any modal window left open, otherwise the close command will fail.
But if the app crashed, you have to resort to UA.CheckApps method or external commands.
QuitAppName
if AppName.WaitUntilExists (0, NotExistAction.None)
step CloseModalWindows
AppName.Close ()
if AppNamePopup.WaitUntilExists (5, NotExistAction.None)
AppNamePopup.No.Click ()
Boolean AppNameUserAuthenticationLogWaitWhileExists = AppNameUserAuthenticationLog.WaitWhileExists (5)
Sleep (7)
if StoppedWorking.WaitUntilExists (0, NotExistAction.None)
StoppedWorking.CloseProgram.Click ()
step KillAppName
KillAppName
// in case of a crash, it is necessary to kill the app in order to continue testing
List<String> PID
System.Execute (“TASKLIST /FI “”IMAGENAME eq AppName.exe”””, PID)
if ! PID[1].Contains (“INFO: No tasks are running which match the specified criteria.”)
System.Run (“taskkill”, “/f /im AppName.exe”)
LogWarning (“One or more instances of AppName.exe were killed”)
Sleep(5)
After a few months of use, I realised that there are situations where the example of the above post will not reach the Kill step.
I have a slightly different approach now.
I just try to detect the presence of error reporting program, if they are present, something went wrong and something has to be done to keep on testing.
UA.CheckApps does not always detect these situations, i had more succes detecting the error reporting processes and killing the application if they are prresent.
here is an example of an OnFinish AppState, if there are no error reporting processes, the app will close gracefully otherwise brutally.
[ ] // in case of a crash, it is necessary to kill the app in order to continue testing
[ ] List<String> PID
[ ] List<String> PID2
[ ]
[ ] System.Execute (“TASKLIST /FI “”IMAGENAME eq dw20.exe”””, PID)
[-] if ! PID[1].Contains (“INFO: No tasks are running which match the specified criteria.”)
[ ] step KillV8
[ ]
[ ] System.Execute (“TASKLIST /FI “”IMAGENAME eq werfault.exe”””, PID2)
[-] if ! PID2[1].Contains (“INFO: No tasks are running which match the specified criteria.”)
[ ] step KillV8
[ ] step CloseAnyOpenWindow
[ ] step ExitVisionPE
[ ]
Contact Our Team