Emailing a crash.

Hi All,

Am new to the forum and to scripting, so please be gentle! :mrgreen:

I'm using eggplant to track down a crasher in our file-->open routine. Basically, what I want to do is alternate between two files until the app crashes, and email me on the iteration that crashed. My first attempt was the following:
repeat 20000 times
	if imagefound(someimage) then
		typecommand "O"
		typecommand "D"
		click "file1"
		typecommand "W"
		if imagefound("Mac/DontSave") then 
			typetext "d"
		end if
		typecommand "O"
		typecommand "d"
		click "file2"
		typecommand "W"
		if imagefound("Mac/DontSave") then 
			typetext "d"
		end if
		SendMail (to:"[email protected]",subject:"Crash!",body:"The application crashed after "&repeatIndex()&" times")
	end if
end repeat

The problem here is obvious, after the crash, I'd get a bunch of unwanted emails. Also, this method requires me to multiply the repeat index by two in order to get a rough idea of the number of files I had to open. I'm sure there's something I'm missing.

In a related topic, is there any way for Eggplant to compare a different image based on the iteration of the repeat, ie use image4.tiff for comparison the 4th time through the repeat loop?

Thanks for all assistance,



  • EggplantMattEggplantMatt ForumAdmin admin
    Hi, Allen:

    I think you can solve your first problem by simply putting
    exit repeat

    after your SendMail command.

    You can actually perform the multiplication of the repeatIndex() right in the SendMail command like this:
    SendMail (to:"[email protected]",subject:"Crash!",body:"The application crashed after "& 2 * ( repeatIndex() -1 ) &" times")

    I decremented the repeatIndex in the above example because the failure would have occurred on or after the preceding iteration of the loop. And I changed your e-mail to protect you from any spambots that might come ascraping.

    I think you could rework your example a bit to more accurately reflect where the crash occurs:
    put 0 into count
    set crashed to false
    repeat while repeatIndex() <= 20000 and crashed is not true 
    ? ?repeat two times
    ? ?? ?if imagefound(someimage) then 
    ? ? ??? ?typecommand "O" 
    ?? ? ?? ?typecommand "D" 
    ?? ? ?? ?click "file" & repeatIndex() 
    ?? ? ?? ?typecommand "W" 
    ? ?? ?? ?if imagefound("Mac/DontSave") then 
    ? ?? ?? ?? ?typetext "d" 
    ? ?? ?? ?end if 
    ? ?? ?? ?add 1 to count
    ? ?? ?else 
             set crashed to true
    ?? ? ?? ?SendMail (to:"[email protected]",subject:"Crash!",body:"The application crashed after "& count &" times") 
             exit repeat
    ? ?? ?end if 
    ? ? end repeat
    end repeat

    This also demonstrates the use of the repeatIndex() to reference a different image each time through the loop. You can simply concatenate the repeatIndex() onto the basename of the image.

    Hope this helps.
  • Thanks!

    This helps a bunch!

Sign In or Register to comment.