Forum Discussion

baxatob's avatar
baxatob
Community Hero
8 years ago

Can we handle events from the specific test-unit?

Hi,

 

Can we handle events from the specific test-unit?
Say, I have two different tests which fire the same event (or error) be posted to the log. And I want to handle it in different way.

3 Replies

  • shankar_r's avatar
    shankar_r
    Community Hero

    I used to use the Log option as like below in-order to get the Unit name of the script.

     

    In my event handler, I will have different set of Log attributes based on the Unit name and handle it different way.

     

    function test()
    {
          Log.Error("text box is enabled in the login screen","LoginUtility");
    } 
    function GeneralEvents_OnLogError(Sender, LogParams)
    {
          if(LogParams.AdditionalText == "LoginUtility")
          {
                aqFile.WriteToTextFile(Project.Path + "login-logs",LogParams.MessageText,aqFile.ctANSI);
          } 
    }

    I maybe misunderstood the question :)

     

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Not sure you can with the OnLogError or OnLogEvent event handler.  All that can do is work with the log entry as it stands.  There's not much more information passed in to the event handler than what is written to the log.  So, if there is some way you can write to the log something different depending upon the circumstances of the event, then you can use those event handlers.