Forum Discussion

kimmatsumoto's avatar
kimmatsumoto
Contributor
9 years ago
Solved

Dialog windows in Delphi XE 10 (Rad Studio XE 10)

The application I'm testing is compiled with Rad Studio XE 10 and the dialog window is detected as: Sys.Process('download').Window('#32770', 'download').Window('DirectUIHWND').Window('CtrlNotifySink...
  • EnergizerBunny's avatar
    9 years ago

    Our company uses the same framework for our applications. It is our policy to NOT compile the applications with debug information. So for the past 16 years I have been testing these applications with QARun, TestPartner, and now exclusively TestComplete.

    The issue of the popup window having two different class names was solved 16 years ago and I have converted the code to TestComplete. We use TestComplete version 11.20.1491.7.

    We do not use name mapping at all and rely on the various Find methods to access the objects.

    The function is called PopupsUniversal. You pass the process object, caption text, and the text of the button to the function. It returns True if the button was clicked.

    The example below should work for the information that you provided.

    Sorry about the indentions, when I copy and paste all tabs are lost.

     

    Sub One
        Dim p
        Set p = Sys.WaitProcess("download", 3000)
        If p.Exists = True Then
            If PopupsUniversal(p, "download", "OK") = True Then
                Log.Message "Clicked the popup."
            Else
                Log.Message "Did not click the popup."
            End If
       Else
            Log.Error "Process not found."
        End If
    End Sub

     

    Function PopupsUniversal(objProcess, svCaption, svButtonText)
        Dim f, objButton
        PopupsUniversal = False
        If Win32API.FindWindow("TMessageForm", svCaption) <> 0 Or Win32API.FindWindow("#32770", svCaption) <> 0 Then
            Set f = objProcess.FindEx(Array("WndClass", "WndCaption"), Array("TMessageForm", svCaption), 1, True, 500)
                If f.Exists = False Then
                    Set f = objProcess.FindEx(Array("WndClass", "WndCaption"), Array("#32770", svCaption), 1, True, 500)
                End If
                If f.Exists = True Then
                    f.Activate
                    Set objButton = f.Find(Array("WndClass", "WndCaption", "Visible"), Array("Button", svButtonText, True), 10, True)
                    If objButton.Exists = False Then
                        Set objButton = f.Find(Array("WndClass", "ObjectIdentifier", "Visible"), Array("Button", svButtonText, True), 10, True)
                    End If
                    If objButton.Exists = False Then
                        Set objButton = f.Find(Array("WndClass", "Caption", "Visible"), Array("Button", svButtonText, True), 10, True)
                    End If
                    If objButton.Exists = False Then
                        Set objButton = f.Find(Array("WndClass", "WndCaption", "Visible"), Array("TButton", svButtonText, True), 10, True)
                    End If
                    If objButton.Exists = False Then
                        Set objButton = f.Find(Array("WndClass", "ObjectIdentifier", "Visible"), Array("TButton", svButtonText, True), 10, True)
                    End If
                    If objButton.Exists = False Then
                        Set objButton = f.Find(Array("WndClass", "Caption", "Visible"), Array("TButton", svButtonText, True), 10, True)
                    End If
                    If objButton.Exists = True Then
                        objButton.HoverMouse
                        objButton.Click
                        PopupsUniversal = True
                    End If
            End If
        End If
    End Function