Jump to content
Sign in to follow this  
pammi

Handling Test application Crash during automation

Recommended Posts

pammi

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

Share this post


Link to post
Share on other sites
JohnOne

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.

Share this post


Link to post
Share on other sites
pammi

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"

Share this post


Link to post
Share on other sites
pammi

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"

.........

.........

.........

.........

Share this post


Link to post
Share on other sites
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
pammi

@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.

Share this post


Link to post
Share on other sites
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Zedna

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

Share this post


Link to post
Share on other sites
JohnOne

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.

Share this post


Link to post
Share on other sites
pammi

@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"?

Share this post


Link to post
Share on other sites
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
pammi

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.

Share this post


Link to post
Share on other sites
pammi

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?

Share this post


Link to post
Share on other sites
JohnOne

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.

Share this post


Link to post
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
Sign in to follow this  

×