cancel
Showing results for 
Search instead for 
Did you mean: 

Creating Event Handlers for TestComplete Events

SOLVED
Highlighted
Occasional Contributor

Creating Event Handlers for TestComplete Events

Hello,

 

I was following the link: https://support.smartbear.com/testcomplete/docs/testing-with/advanced/handling-events/creating-handl..., 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;

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: Creating Event Handlers for TestComplete Events

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.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

3 REPLIES 3
Community Hero

Re: Creating Event Handlers for TestComplete Events

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?


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Occasional Contributor

Re: Creating Event Handlers for TestComplete Events

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

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.

 

 

 

Community Hero

Re: Creating Event Handlers for TestComplete Events

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.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post