Forum Discussion

seanMRoss's avatar
seanMRoss
Contributor
13 years ago

How are events called in testcomplete?

Hi Folks 



For about 2 weeks I have been trying to write events catch UnexpectedWindows in testcomplete using JScript.



I cannot figure how to call the event, What do I define Sender as?






function MainFunction()

{





    CreateSomething;



    //code where unexpected window is triggered

    GeneralEvents_OnUnexpectedWindow(Sender, Window, LogParams)



}

function GeneralEvents_OnUnexpectedWindow(Sender, Window, LogParams)

{

  //Send to logs

}
  • Hi Sean,



    In my experience, you do not call the EventHandlers directly. Instead, Test Complete calls your event handlers when an event is encountered.



    I have done the following to handle events:



    1. Add the Events Project Item to my project.

    2. Expand the Events Project Item found in my project.

    3. Double click the GeneralEvents item.

    4. Double click the event handler you wish to use.

    5. Select the file that contains the event handler code you wrote.

    6. Select the function that contains the event handler code you wrote.

    7. Click OK.



    Now, when Test Complete encounters that event, it should fire your code.



    Hope this helps!