pammi Posted May 18, 2012 Share Posted May 18, 2012 Hi Everyone, I am writing scripts to test a window's application. There are hundreds of scripts and there are chances that the application I am testing may crash at any point of time. I want to handle this situation so that the running test script which resulted in a crash wont stop the execution and will move on to the next script when a crash is found. How can I do this?? Any ideas. Thanks in advance Link to comment Share on other sites More sharing options...
JohnOne Posted May 18, 2012 Share Posted May 18, 2012 Look for the crash window would be my first suggestion. But without details of what application you are testing and how your scripts are running it's pretty difficult to suggest anything else. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
pammi Posted May 18, 2012 Author Share Posted May 18, 2012 JohnOne, i am testing C++ application. I have a main script which contains subscripts in the below manner. When I run the main script the subscripts mentioned starts executing one by one. During the executionof these subscripts there are chances tht the application may crash at any point. How to look for the crash window. You mean I need to insert a code to look for a window with text something like "error"? I am running the scripts in the following manner : #include "TS_17_001.au3" #include "TS_17_002.au3" #include "TS_17_003.au3" #include "TS_17_004.au3" #include "TS_17_005.au3" #include "TS_17_006.au3" #include "TS_17_007.au3" #include "TS_17_008.au3" #include "TS_17_009.au3" #include "TS_17_010.au3" #include "TS_17_011.au3" #include "TS_17_012.au3" #include "TS_17_013.au3" #include "TS_17_014.au3" #include "TS_17_015.au3" Link to comment Share on other sites More sharing options...
pammi Posted May 18, 2012 Author Share Posted May 18, 2012 Below is the content of main script : #Include <Excel.au3> #include<globalFunc.au3> ; Global Function ;Open the test specification file. $sFilePath1 = "D:Projectsabc.xlsx" ;This file should already exist $oExcel = _ExcelBookOpen($sFilePath1) If @error = 1 Then MsgBox(0, "Error!", "Unable to Create the Excel Object") Exit ElseIf @error = 2 Then MsgBox(0, "Error!", "File does not exist") Exit EndIf _ExcelSheetActivate($oExcel, "Test Spec-Report") #include "TS_17_001.au3" #include "TS_17_002.au3" #include "TS_17_003.au3" #include "TS_17_004.au3" #include "TS_17_005.au3" #include "TS_17_006.au3" #include "TS_17_007.au3" #include "TS_17_008.au3" #include "TS_17_009.au3" #include "TS_17_010.au3" #include "TS_17_011.au3" #include "TS_17_012.au3" #include "TS_17_013.au3" #include "TS_17_014.au3" #include "TS_17_015.au3" ......... ......... ......... ......... Link to comment Share on other sites More sharing options...
water Posted May 18, 2012 Share Posted May 18, 2012 I would use a multi-step approach:Every test script should do a test to check that the c++ application is still running (the process still exists or ...) immediately after beeing startedEvery step of your test script should be robust enough to handle a crash during testing by checking the return value and @error of each AutoIt statementIf the c++ application throws an error screen the main testing script should handle this situation. In my OutlookEX UDF you can start an exe that handles security popups and clicks them away. You could handle your error windows accordinglyJust my 0.02 $ My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
pammi Posted May 18, 2012 Author Share Posted May 18, 2012 @water, Once the application crashes an error popup window will appear and I need to click "close the program" button to close the application. you said "If the c++ application throws an error screen the main testing script should handle this situation." How to do this? Can you please elaborate. i am new to autoit. Link to comment Share on other sites More sharing options...
water Posted May 18, 2012 Share Posted May 18, 2012 The main script starts an exe and passes some information as parameters (process ID of the main script, wait time before checking for the error window etc.). The exe (compiled AutoIt script) does the following in a loop: Check if the error window exists. If yes: click on the "close the program button". Check if the main script has terminated (checks for the passed processID). If yes, terminate the exe too. So you have two scripts running at the same time. The script doing the tests and the script checking for and handling the error window. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Zedna Posted May 18, 2012 Share Posted May 18, 2012 @water,Once the application crashes an error popup window will appear and I need to click "close the program" button to close the application.you said "If the c++ application throws an error screen the main testing script should handle this situation."How to do this? Can you please elaborate. i am new to autoit.Look at AdlibEnable() Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
JohnOne Posted May 18, 2012 Share Posted May 18, 2012 With the AdLibRegister suggestion, maybe a func like this would work. Func IsAppCrash() $aHungApp = DllCall("user32.dll", "int", "IsHungAppWindow", "hwnd", $GlobalHWND) ; handle of app window must be global for use with Adlib* functions If @error Then Exit MsgBox(0, "DllCall Error", @error) EndIf If $aRet[0] Then ;deal with it EndIf EndFunc ;==>IsAppCrash AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
pammi Posted May 18, 2012 Author Share Posted May 18, 2012 @JohnOne,In my scenario the application doesn't Hang. Once it crashes an error popup window will appear and I need to perform the popup window close operation. So does the "IsHungAppWindow" in Dllcall function works in this case? Or do I need to use some other function in Dllcall inplace of "IsHungAppWindow"? Link to comment Share on other sites More sharing options...
JohnOne Posted May 18, 2012 Share Posted May 18, 2012 If I were you I'd just test it. But as stated, the best way would be to just check the error window exists and take it from there. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
water Posted May 18, 2012 Share Posted May 18, 2012 If performance doesn't matter I would stay with the AdLibRegister approach. Your function could look a bit like: AdlibRegister("WaitForErrorWindow", 250) Func WaitForErrorWindow() If WinExists("Window title", "Text in the window") Then ControlClick(...) EndFuncThe function is called 4 times per second (every 250ms). It checks for a window with a specific title and a specific text on it. If found it clicks a button. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
pammi Posted May 19, 2012 Author Share Posted May 19, 2012 Thanks a lot JohnOne and Water I dont have access to my application from home. Il get back to u guys with result. Thanks once again. Link to comment Share on other sites More sharing options...
pammi Posted May 21, 2012 Author Share Posted May 21, 2012 JohnOne, The following worked ... AdlibRegister("_IsAppCrash",250) Run("C:abc.exe") sleep(1000) send("!vg") sleep(2000) Func _IsAppCrash() if winexists("abc","") then $HWND=WinGetHandle("abc") $aHungApp = DllCall("user32.dll", "int", "IsHungAppWindow", "hwnd", $HWND) ; handle of app window must be global for use with Adlib* functions If @error Then MsgBox(0, "DllCall Error", @error) EndIf If $aHungApp[0]=0 Then ControlClick("abc.exe","&Close","") EndIf Else exit endif EndFunc I have one more question. Do I have to include this in all the scripts?. Can't we declare this function as global and call it in all the scripts? Link to comment Share on other sites More sharing options...
JohnOne Posted May 21, 2012 Share Posted May 21, 2012 There are a number of ways you could try. Like #include all your scripts in one main script Have just that running in a separate script Or have it running in the main script that is controlling the others AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
pammi Posted May 22, 2012 Author Share Posted May 22, 2012 thanks for your help guys Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now