Forum Discussion

pravin_k99's avatar
pravin_k99
Contributor
5 years ago
Solved

Why cant I see all my tests in event handler?

When I go and add a new event handler - lets say for an event OnLogError, I only see few scripts and no keyword test. Any reason?

I can definitely add a new one but I would rather use an existing one

  • tristaanogre's avatar
    tristaanogre
    5 years ago

    You can run a KWT as an event handler.  However, keep in mind, that there are certain objects and parameters that need to be passed in.  So, if the KWT doesn't have the proper parameters, it's filtered out.

  • Hi pravin_k99 

     

    I believe what tristaanogre is referring to which parameters your keyword test is configured with.  Just like you can configure a function to have parameters, you can configure a Keywordtest to have parameters.

     

    If you let TC generate the event as a script, you will see the function is defined as such:

    function GeneralEvents_OnLogError(Sender, LogParams)

    If you create a new KWT, say OnLogErrorKWT and add the same two parameters :


     

    The KWT will be selectable:

     

     

    Thanks tristaanogre, I learned something new :smileyvery-happy:

5 Replies

  • AFAIK You can't run a KWT as an event.  You have no choice but to run a script, but there's nothing stopping you from calling a Keword Test - KeywordTests.EventHandlerKeywordTest.Run() from within the script.  If the keywordtest you called however causes the event to fire e.g. Logging a message, you are stuck in a loop.  I would try and keep the work done in an event to the bare minimum - rather handle those possible issues in your scripts/KWTs first and avoid KWTs being called from within events.  

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      You can run a KWT as an event handler.  However, keep in mind, that there are certain objects and parameters that need to be passed in.  So, if the KWT doesn't have the proper parameters, it's filtered out.