Forum Discussion

bommareddy's avatar
bommareddy
Contributor
8 years ago
Solved

How to handle UnexpectedWindow/Overlapping window using the script or General Events?

Hi All,

 

My application throws popup for every 3-5 Min. Script can proceed further by clicking on Ok button in the popup.

 

But how to recognise this popup using testcomplete dynamically?

 

Ex: While running the script, In middle if any popup appears TestComplete is not triggering it as UnexpectedWindow/Overlapping window. So that the webpage objects are going to "VisibleOnScreen=False" due to this popup. If objects are in Invisible state, we can't proceed further.

 

Please find the screen shot of the unwanted popup in the application and also Let me know if your require any other details in this regard.

 

 

Regards,

BommaReddy

 

  • Hi All,

     

    As a workaround, I got the better solution to handle Windowless popup(Model Based popup) 

     

    By using Timer Object we can overcome this problem. Write the following code in event handlers.

     

    OnStartTest:

    Sub OnStartTest(Sender)
      Dim MyTimer
      Set MyTimer = Utils.Timers.Add(8000, "unit1.TimerRoutine", True)
      MyTimer.Name = "ModelPopUp"
      Log.Message "Timer ON"
    End Sub

    OnStopTest:

    Sub OnStopTest(Sender)
      Utils.Timers.Items("ModelPopUp").Enabled = False
      Log.Message "Timer OFF"
    End Sub

    unit1.TimerRoutine:

    Function TimerRoutine
      'write the code to check whether popup exists or Not
      If popup=True Then
         'close popup (or) Click
      End If
    End Function

    Before script starts, the controller will go to OnStartTest and activate Timer Object. Once Timer triggers, TestComplete pauses the test to run the timer’s routine. The test is resumed after the timer routine has finished running.

     

    So for every 8sec, i am checking whether Windowless popup(Model Based popup) exists or not. For more details on Timer object click here

     

    Regards,

    BommaReddy

     

17 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    As I understand it, the TestComplete event for Unexpected/Overlapping window triggers if you attempt to interact via mouse click or keystroke with a component on the underlying window. So, whether or not the component is visible on screen shouldn't matter to TC. Do you have code or something in your tests to check for "VisibleOnScreen" before proceeding? If so, you may want to modify that to only check the "VisibleOnScreen" property when it is necessary to do so.

    In any case, once the unexpected/overlapping window event gets triggered, you can create an event handler that will do the necessary button click as you described. See https://support.smartbear.com/viewarticle/84027/ for more information.

    • bommareddy's avatar
      bommareddy
      Contributor

      Hi Tristaanogre thanks for your reply.

       

      My code:

      1. Set objAbc = xyz
      2. aqUtils.Delay 5000
      3. objAbc.Click

       

      Consider this as example. During the execution process of the second line, the Unexpected/Overlapping window triggers. At Line 3, i am trying to click on objAbc object. But the "objAbc" is "VisibleOnScreen=False". 

       

      I am performing click action on the main webpage. During this general events are not triggering(Unexpected/Overlapping) for this event.

       

      I have return seperate code in eventHandlers

         Sub OnOverlappingWindow(Sender, Window, OverlappingWindow, LogParams)
              'code to handle overlapping/Unexpected window
         End Sub

       

      Regards,

      BommaReddy

       

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        As noted in the support article that I linked, there are certain situations where the overlapping window event doesn't fire. Please check your application to see if it meets those criteria. If so, you may need to write your own code so that, before interacting with your main application, you check for the popup.  Something like:

         

        Set objAbc = xyz
        aqUtils.Delay 5000
        CheckAndClosePopup()
        objAbc.Click

        where the function CheckAndClosePopup would have something like

         

        if (MyApp.WaitChild('PopUpWindow', 100).Exists){
            MyApp.PopUpWindow.OKButton.Click()
        } 

        That's the best I can do for you. There could be other ways using timers and such but that might end up putting a heavier load on your test project performance.

    • bommareddy's avatar
      bommareddy
      Contributor

      Thanks dude for your support :smileyhappy:

       

      Is there anyway to identify Model Window popup dynamically while script execution process i.e like General Events(UnexpectedWindow/Overlapping)?

       

       

      Regards, BommaReddy

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        There's not a way to create custom events to be handled in the same way.

         

        However, you could create a Timer Object (https://support.smartbear.com/viewarticle/82264/) that would execute every so many seconds. It's not an event handler necessarily but you could set up a timer that would check to see if the window exists and, if it does, click the OK button on it.