Forum Discussion

kahlerb's avatar
kahlerb
New Contributor
14 years ago

How to control from wich unit a EventHandler recognises Events

Hi there,



im using a OnLogError EventHandler. I want it only to recognise Events wich were thrown by one of my scripting unit.



Is it possible to check the Sender and how could I do this? Or is there an other possibility to do this?



The Eventhandler looks like this




Sub GeneralEvents_OnLogError(Sender, LogParams)

    MessageText = LogParams.Str 

    If InStr(MessageText, "The window was destroyed during method execution.") Then    

        



 



Log.Event("Event recognised")

        LogParams.Locked = true 

    End If

End
Sub



 



2 Replies

  • Hi,


    Currently, there is no way to identify an event sender.


    Can I ask what you're trying to do? Perhaps there's another way to achieve the same result.


    If you just need to cancel posting messages to the test log when the desired routine is called, set the Log.Enabled property to False. For an example demonstrating how to use this property, see http://smartbear.com/support/viewarticle/14185/ in the online documentation.

  • kahlerb's avatar
    kahlerb
    New Contributor
    Hi Margaret, thank you for your help.



    So i got tests for an app, where sometimes a window is (correctly) destroyed during method execution and sometimes not. I've written the OnLogError Event Handler to recognise this.



    My solution was now not to check the "LogParams.Str".



    Actually I check if the name of the object under test is part of "LogParams.AdditionalText" (with the InStr()-Function)



    So that works really good, and the test cases recognises properly where a destroyed window is correct behavior and where not.