Ask a Question

Iterative call to handler in TestComplete

wmtan01
Contributor

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 3
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

 

 

Regards,
  /Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================

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!

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:

wmtan01_1-1629321928177.png

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:

 

wmtan01_0-1629321914097.png

 

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

 

cancel
Showing results for 
Search instead for 
Did you mean: