Contributions
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; }1.2KViews0likes0CommentsRe: 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 theWin32 Controls and Windows | Edit boxlist 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 Function1.2KViews0likes1Comment