Forum Discussion

wmtan01's avatar
wmtan01
Contributor
3 years ago

Iterative call to handler in TestComplete

Hi!

 

We use TestComplete to test multiple browsers all at the same time. RTC applications (which we have) require us to have 2 or more actors/users active during the test. This leads to us encountering "Ambiguous Browser Recognition" warnings during runtime. To make logs cleaner I attempted to make an OnLogWarning Event handler that checks if the message is "Ambiguous Browser Recognition" and if it is, don't log it. It seems to work fine but sometimes TestComplete throws a popup saying that iterative calls were being made to the handler. Which doesn't make sense since I'm not calling Log.Warning on my handler which was suggested in the info page for the OnLogWarning event.

 

Here's my handler:

set SuppressedWarnings = CreateObject("System.Collections.ArrayList")
SuppressedWarnings.Add "Ambiguous browser recognition."


Sub Warning_Suppress(Sender, LogParams) 
  if SuppressedWarnings.Contains(LogParams.MessageText) then
    LogParams.Locked = True
    Log.Message("Suppressed warning: " + LogParams.MessageText)
  end if
End Sub

 

I really want to clean up the logs and remove these warnings, is there an easier way to do this? Or if someone can tell me why my handler would do an iterative call that would be great. 

3 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    Personally I would try to eliminate the "Ambiguous Browser Recognition" warning. Can your testing be done using two different browsers, e.g. Chrome and Firefox?

    To avoid iterative calls, you may consider use of public flag like in this pseudo-code:

     

    Public bIsInHandler = False
    ...
    Sub Warning_Suppress(Sender, LogParams)
      If (bIsInHandler) Then
        Exit Sub
      Else
        bIsInHandler = True
      End If
    
      if SuppressedWarnings.Contains(LogParams.MessageText) then
        LogParams.Locked = True
        Log.Message("Suppressed warning: " + LogParams.MessageText)
      end if
    
      bIsInHandler = False
    End Sub

     

     

    • wmtan01's avatar
      wmtan01
      Contributor

      Hi!

       

      We are using two browsers but the namemapping is still under one browser. We do Aliases.browser where the identifier for browser is just the Object Type. It's not that great in terms of performance but it gets the job done for now. 

       

      I'll try out this flag for in Handler and see if I still get the system pop up. Thanks!

    • wmtan01's avatar
      wmtan01
      Contributor

      Alright after trying out that fix which in theory should fix it up as it definitely would not allow recursive calls, the system popup still showed up.

       

      Something weird is definitely happening here.

      Here is the log when I'm not doing any handler on the event:

      Notice that there is only 1 instance of the warning. And no other warnings after it.

       

      But with the handler here is what's happening:

       

       

      It seems that the OnLogWarning event is being triggered repeatedly causing the handler to be repeatedly be called, though not by the handler itself.. since as the log shows bIsInHandler is False (that's what I'm logging)...

       

      And to make it even weirder, I modified the handler to just be this and it still triggered the system pop up. Based on the original log there should just be 1 warning, so only 1 trigger of the event, unless the event itself is causing another event which seems to be the case...

      bIsInHandler = False
      
      set SuppressedWarnings = CreateObject("System.Collections.ArrayList")
      SuppressedWarnings.Add "Ambiguous browser recognition."
      
      
      Sub Warning_Suppress(Sender, LogParams)
        Log.Message(bIsInHandler)
        If (bIsInHandler) Then
          Exit Sub
        Else
          bIsInHandler = True
        End If
        'if SuppressedWarnings.Contains(LogParams.MessageText) then
         ' LogParams.Locked = True
          'Log.Message("Suppressed warning: " + LogParams.MessageText)
          'Log.Error("TEST")
        'end if
        'bIsInHandler = False
      End Sub