Forum Discussion
Hi Rebecca,
Unfortunately, the latest version of TestComplete (ver. 9) doesn't provide you with such functionality. However, if you could explain why you don't want to add event controls via the Event Control editor, it would be easier for our developers to make a decision about implementing this functionality.
As for now, if you need to track from a script whether the needed event is handled, I have the following workaround for you:
1. Add the needed event control via the Event Control editor manually and specify the script routine that will store its handler.
2. Add the project variable of the Object type to the [url=]Variables[/url] page of the Project editor. In my example, the name of the created variable is OnLogErrorHandler. This variable will indicate whether the OnLogError event is handled.
3. Add the following code to the script unit that must store the handler for the needed event:
function GeneralEvents_OnLogError(Sender, LogParams)
{
if (Project.Variables.OnLogErrorHandler != null)
{
var Handler = Project.Variables.OnLogErrorHandler;
Handler(Sender, LogParams);
}
}
function Main()
{
Log.Error("Error1");
Project.Variables.OnLogErrorHandler = TestHandler;
Log.Error("Error2");
}
function TestHandler(Sender, LogParams)
{
LogParams.Str = "Handled: " + LogParams.Str;
}
4. Run the Main function.
5. To command TestComplete not to handle the OnLogError event, you just need to comment the Project.Variables.OnLogErrorHandler = TestHandler; line in the Main function.
I hope this information helps :)
Related Content
- 5 years ago
- 5 years ago