Forum Discussion

pmahesha's avatar
pmahesha
Occasional Contributor
13 years ago

Checking Tooltip

Sir,

I have one difficulty in checking the tootip.



I am able to hover the mouse pointer over the command button from test complete and it does show the tooltip window. But how do I read the tooltip window propertiey? I do not know the window name of the tooltip window and I will have to read from script only. The moment I remove the mouse pointer, tool tip vanishes. So I am not sure how to test for tooltips.

4 Replies

    • ristokochevski's avatar
      ristokochevski
      New Contributor

      Hi,

       

      The link to the answer which you've posted, no longer exists (obviously because it was posted 7 years ago).

       

      Can you add the correct link/answer to this question?

       

      Best,

      /R

      • TatyanaWeb's avatar
        TatyanaWeb
        Staff

        The link seems to work correclty. In case you cannot open it, here is the text:

         

        Operating System: Windows XP, Windows Vista

        The sample script obtains all tooltips of the specified control and posts information about them to the Test Log. Before you execute the script, add the *tooltips_class32* class to the Win32 Controls and Windows | Edit box list in the Object Mapping settings of your TestComplete project. When executing the script, you need to hover the mouse pointer over a control containing tooltips (to make the tooltips be displayed on the screen).

        VBScript

        Sub Test
          Dim i, p, w, startTime, timeout, tooltips, tooltip, tooltipText, tooltipFound
          
          timeout = 30000
          
          Set p = Sys.Process("PROCESS_NAME")
          Set tooltipsText = CreateObject("Scripting.Dictionary")  
          startTime = GetTickCount()
          Do 
            Call p.Refresh()
            Set tooltips = GetTooltips(p)
            For i = 0 to tooltips.Count - 1
              Set tooltip = tooltips.Item(i)
              If (tooltip.Visible) Then
                If (aqObject.IsSupported(tooltip, "wText")) Then
                  If ("" <> tooltip.wText) Then
                    Call tooltipsText.Add(tooltipsText.Count, tooltip.wText)
                  End If
                ElseIf (aqObject.IsSupported(tooltip, "Text")) Then
                  If ("" <> tooltip.AccessibleName) Then
                    Call tooltipsText.Add(tooltipsText.Count, tooltip.AccessibleName)
                  End If
                End If
              End If
            Next
          Loop While ((0 = tooltipsText.Count)  And (timeout > GetTickCount() - startTime))  
           
          For i = 0 to tooltipsText.Count - 1 
            Call Log.Message("The text of tooltip #" & i &_
                             " is:" & vbCrLf & tooltipsText.Item(i))
          Next
        End Sub
         
        Function GetTooltips(p)
          Dim i, objectIndex, tempObjects, tooltips
          
          Set tooltips = CreateObject("Scripting.Dictionary")   
          For i = 0 To 1
            Select Case i  
              case 0  tempObjects = p.FindAllChildren("WndClass", "*tooltips_class32*")
              case 1  tempObjects = p.FindAllChildren("ClrClassName", "ToolTipFormEx")
              Case Else  Log.Error("The " & i & " index is not known")
            End Select
            For objectIndex = 0 To UBound(tempObjects)
              Call tooltips.Add(tooltips.Count, tempObjects(objectIndex))     
            Next
          Next
          Set GetTooltips = tooltips 
        End Function