Forum Discussion

trajmo's avatar
trajmo
Occasional Contributor
6 years ago

Creating Event Handlers for TestComplete Events

Hello,

 

I was following the link: https://support.smartbear.com/testcomplete/docs/testing-with/advanced/handling-events/creating-handlers/for-testcomplete-events.html, for creating an event handeler for unexpected windows in my tests, but i cannot figure out how to define a messageText in the logParams. I am sending you the code i am using in my script and had copied from Smartbear support web site. 

I am sending a screenshoot from the error i get,

 

Looking forward for your response,

 

Thanks in advance.

 

procedure ProjectEvents1_OnUnexpectedWindow(Sender; Window; LogParams);

begin
Log.Picture(Sys.Desktop, 'Image of the whole screen');
LogParams.MessageText :='ok';
// You can use the following line to cancel
// posting of the default TestComplete messages
// LogParams.Locked := True;
end;

  • That's not how event handlers are triggered.  An event is something that automatically happens by TestComplete.  The script code you created will be triggered when the event occurs.  Firing it manually as you have will not work as it is dependant upon particular objects being present.  When the event is fired, the LogParams object is created with all the proper fields and methods.

    If you followed the steps for generating the event and linking it, then your code should work simply when the event is triggered.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Question: Are you getting this error during the actual triggering of the event or are you running the routine independantly of the larger project?

     

    What happens if you put a breakpoint on the line and investigate the LogParams object?

    • trajmo's avatar
      trajmo
      Occasional Contributor

      I am really new in this, for sure i am making a mistake somewhere, and i really need help.

      I as already mention i was following the steps from this article https://support.smartbear.com/testcomplete/docs/testing-with/advanced/handling-events/creating-handlers/for-testcomplete-events.html 

      Firstly I had created a event for unexpected window and  then i had created a event handeler with code i've pasted above, and the event is used with a run script code in the keyword test. As a step where I suspeced the pop-up window will apear. 

      I dont know how to get to this step to define a messageText for the LogParams as it is shown on the attached photo.

       

       

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        That's not how event handlers are triggered.  An event is something that automatically happens by TestComplete.  The script code you created will be triggered when the event occurs.  Firing it manually as you have will not work as it is dependant upon particular objects being present.  When the event is fired, the LogParams object is created with all the proper fields and methods.

        If you followed the steps for generating the event and linking it, then your code should work simply when the event is triggered.