Forum Discussion

JonatasFischer's avatar
JonatasFischer
New Contributor
10 years ago

WaitWindow is returning a ramdom inactive window and not the top one

 

After I instaled the last version of testcomplete (and the sugested update) I'm having error at all my project. I'm having to review all the work I did with the trial version (while I waith the company buy testcomplete).

The problem is occurs when I call the function WaitWindow. For windows without caption (title) . If there are not window active the testcomplete is returning a hiddem inactive window. And all my application is raising errors.

I use this simples pattern

  set wAlertaVenc = Sys.Process("central").WaitWindow("_TForm", "*", 1,1000)
  If wAlertaVenc.Exists then
    Sys.Process("central").Window("_TForm", "", 1).VCLObject("OK").Click
  end if

 

There are something I could do to avoid this error? there are any patch I could apply to solve this?

 

  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor
    'Specifying a wildcard (*) could return an unexpected form
    'Removed wildcard (*)
    
    Set wAlertaVenc = Sys.Process("central").WaitWindow("_TForm", "", 1,1000)
    
    If wAlertaVenc.Exists And wAlertaVenc.Visible And wAlertaVenc.Enabled Then
        Sys.Process("central").Window("_TForm", "", 1).VCLObject("OK").Click
    End If
  • According to the TestComplete Help, "empty strings specified as the WndCaption parameter's value are interpreted as strings that contain an asterisk (“*”), that is, TestComplete interprets such window captions not as empty strings, but as any strings."

     

    What you need to do is after you test to see if the object exists, then test to see if it is also visible.

     

    If objToCheck.Exists = True Then
          If objToCheck.Visible = True Then
                ' Do your action here.
          End If
    End If

    • JonatasFischer's avatar
      JonatasFischer
      New Contributor

      Hi

       

      I did the sugestions you give me.

      Altought, even when doing all the tests you sugest it didn't solve my problem.

      My problem is:

      I had a alert window over all my windows.

      I do the code to find the active windows (the alert), so I could close it.

      However, testcomplete is returning a closed ( and invisible) window.

      The software I'm testing is developed with delphi, and the alert is a application.messagebox alert.

       

      I need to close that alert!

       

      Does someone have a idea that could help-me?

       

      The code below doesn't help too.

       

      set wAlertaVenc = Sys.Process("central").WaitWindow("_TForm", "Atenção", 1,1000)
        If wAlertaVenc.Exists then
          Sys.Process("central").Window("_TForm", "", 1).VCLObject("OK").Click
        end if

      • AlexKaras's avatar
        AlexKaras
        Icon for Champion Level 3 rankChampion Level 3

        Hi,

         

        .WaitWindow("_TForm", "Atenção", 1,1000) specifies exact unique window of your application. If you see the alert window on the screen, but the window returned by the WaitWindow() function is invisible, this means that more than one alert window exists in the tested application (this can easily be verified with the help of the ObjectBrowser) and the one you are referencing to is hidden at this moment.

         

        Assuming that all alert windows are direct children of the process, I can suggest the following code (untested, of top of my head):

        Set wAlertaVenc = Sys.Process("central").FindChild(Array("WndClass", "WndCaption", "Visible"), Array("_TForm", "Atenção", True), 1)

        If (wAlertaVenc.Exists) Then
            Call wAlertaVenc.VCLObject("OK").Click
        End If

         

        Does this help?