Jump to content

Handling Test application Crash during automation


Recommended Posts

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

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

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

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 started
  • Every 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 statement
  • If 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 accordingly

Just 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 - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

@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

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 - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

@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()

Link to comment
Share on other sites

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

@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

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(...)
EndFunc
The 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 - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...