cancel
Showing results for 
Search instead for 
Did you mean: 

Checking Tooltip

Highlighted
Occasional Contributor

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 4
Highlighted
Staff

RE: Checking Tooltip

Hi,



You can find an example here.
------
Yuri
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
New Contributor

Re: RE: Checking Tooltip

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

Highlighted

Re: RE: Checking Tooltip

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
SmartBear Web Team
Highlighted

Re: RE: Checking Tooltip

JScript

function Test()
{
  var i, p, w, startTime, timeout, tooltips, tooltipText, tooltipFound;
  
  timeout = 30000;
  
  p = Sys.Process("PROCESS_NAME");
  tooltipsText = new Array();
  startTime = GetTickCount();
  do {
    p.Refresh();
    tooltips = GetTooltips(p);
    for(i = 0; i < tooltips.length; i++) {
      if (!tooltips[i].Visible) {
        continue;
      } 
      if (aqObject.IsSupported(tooltips[i], "wText")) {
        if ("" != tooltips[i].wText) {
          tooltipsText[tooltipsText.length] = tooltips[i].wText;
        }
      }
      else if (aqObject.IsSupported(tooltips[i], "Text")) {
        if ("" != tooltips[i].AccessibleName) {
          tooltipsText[tooltipsText.length] = tooltips[i].AccessibleName;
        }
      }
    }
  }while((0 == tooltipsText.length) && (timeout > GetTickCount() - startTime));
  
  for(i = 0; i < tooltipsText.length; i++) {
   Log.Message("The text of tooltip #" + i + " is:\r\n" + tooltipsText[i]);
  }
}
 
function GetTooltips(p)
{
  var i, objectIndex, tempObjects, tooltips;
  
  tooltips = new Array();
  
  for(i = 0; i < 2; i++) {
    switch(i) {
      case 0:
        tempObjects = VBArray(p.FindAllChildren("WndClass", 
                                "*tooltips_class32*")).toArray();
        break;
        
      case 1:
        tempObjects = VBArray(p.FindAllChildren("ClrClassName", 
                                "ToolTipFormEx")).toArray();
        break;
        
      default:
        Log.Error("The " + i + " index is not known");
        break;
    }
    for(objectIndex = 0; objectIndex < tempObjects.length; objectIndex++) {
      tooltips[tooltips.length] = tempObjects[objectIndex];
    }
  }
  return tooltips;
}
SmartBear Web Team
New Here?
Join us and watch the welcome video:
Announcements
Script Wanted
Let's start July with new challenges!

Create a script to pass custom command-line arguments as a test parameter for the TechCorner tag!

Will you dare to take the challenge?


Top Kudoed Authors