navigation
 Tuesday, February 12, 2008

There are many times when looking over the Test Log after an unsuccessful test it would be useful to know the state of the machine at the time of the error.  In particular, it would be nice to see a picture of the desktop (or your application under test) at the time of error being posted to the log. Now, if you are doing the error posting from you script, it is easy as one of the parameters for Log.Error allows for posting a picture.  But if, TestComplete posts the error it is harder.  The best method I have found is to use the OnLogError event of TestComplete and post a message just before the error with the picture.  To do this:

  1. Expand the "Events" Project Item in the Project Explorer
  2. Double Click on "GeneralEvents" Project Item in the Project Explorer.
  3. In the "GeneralEvents" editor find the "OnLogError" event and click the "New" button
    EventHandling001
  4. Click the "OK" button on the New Routine Dialog.
  5. Add the logic to the routine to post a message.

[Jscript]

function GeneralEvents_OnLogError(Sender, LogParams)
{
   Log.Message(LogParams.Str,"",pmNormal,null,Sys.Desktop);  
} 

[VBScript]

Sub GeneralEvents_OnLogError(Sender, LogParams)
  Call Log.Message(LogParams.Str,"",pmNormal,nothing,Sys.Desktop)
End Sub 

This will get you a message above the error in the test log with the same text and a picture of the desktop at the time of the error.

Name
E-mail
Home page

Comment (Some html is allowed: a@href@title, i, strike, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview