How to capture text from a tooltip using QTP

5,259 views
Skip to first unread message

Dmitry Motevich

unread,
Feb 16, 2007, 8:25:58 AM2/16/07
to mercu...@googlegroups.com
When the user moves the mouse over some objects in his application, a tooltip appears. Is there a way to capture the text displayed in the tooltip?

Solution: Capture the text property for the tooltips_class32 control

1. Move the mouse over the object. If you are testing Web objects, use the MouseOver method, otherwise use the MouseMove method.
2. Wait a second or two for the tooltip to appear.
3. Use descriptive programming to refer to the tooltip object. Most window applications use the "tooltips_class32" class for tooltips. Use the descriptive programming to find the object of that class.
4. Use GetROProperty to capture the text of the tooltip.

Example:


' Windows applications
' Move the mouse over the object.
Window("TextPad" ).WinObject( "Standard" ).MouseMove 22,15
' Wait a second to allow the tooltip to be displayed.
wait 1
' Capture the text of the tooltip object
txt = Window("nativeclass :=tooltips_ class32").GetROProperty( "text")
msgbox txt

' Browser-based application
' Mouseover the object.
Browser("Browser" ).Page("Page" ).Link("Link 1").MouseOver
' Wait a second to allow the tooltip to be displayed.
wait 1
' Capture the text of the tooltip object
txt= Window("nativeclass :=tooltips_ class32") .GetROProperty( "text")
msgbox txt

Note:

If your application uses a different class of object for the tooltip, you may need to use the "Object Spy" (Tools -> Object Spy) to spy on the tooltip to determine the class. After you click the hand button on the Object Spy window, the mouse cursor will turn to a hand icon. Press and hold the CTRL key to change the cursor to the normal state. Mouseover the control to bring up the tooltip. Once the tooltip is up, release the CTRL key and click on the tooltip immediately, before it disappears.
If you cannot use the Object Spy to determine the class of the tooltip object, you may need to contact your developer for this information.

--
Dmitry Motevich

Ganesh muralidharan

unread,
Dec 5, 2012, 3:08:07 PM12/5/12
to mercu...@googlegroups.com
Hi,

It has been sometime since Dmitry has responded to queries. Other experts in this group please respond.

-- 
Regards,
Moderator

On Wed, Dec 5, 2012 at 2:59 PM, elgauchocordobe <gustb...@gmail.com> wrote:
Dmitry, tried both ways, it did not work.

txt = Window("nativeclass :=tooltips_ class32").GetROProperty( "text")

returns an error saying Windows is an invalid object. the object that brings up the tooltip is SwfWindow("CSI - Capacity Planning").SwfTable("processGrid") so my code goes something like this

If procViewer.getcelldata(0,6)="0" Then
    SwfWindow("CSI - Capacity Planning").SwfTable("processGrid").mouseMove 5,5

    ' Capture the text of the tooltip object
    txt = Window("nativeclass :=tooltips_ class32").GetROProperty( "text")
    'Reporter.ReportEvent micpass, "Step 1: check Define Statbase task error: the AUT showed an error: " & txt, "End"
    msgbox txt
    msgbox SwfWindow("CSI - Capacity Planning").SwfTable("processGrid").GetROProperty("error provider text")
Else
    Reporter.ReportEvent micFail, "Step 1: check Define Statbase task error: The AUT did not show any errors", "End"
End If

Object spy only returned a new reference to SwfWindow("CSI - Capacity Planning").SwfTable("processGrid") but with a new number.

Any ideas?

--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to Mercu...@googlegroups.com
To unsubscribe from this group, send email to
MercuryQTP+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en




Kamran

unread,
Dec 5, 2012, 4:20:26 PM12/5/12
to mercu...@googlegroups.com

Hi Dimitry,
try to get alt property. I always use alt property to get tooltip, getroproperty("alt").

--
Regards,
Muhammad Kamran

Sumanhyd

unread,
Dec 5, 2012, 9:56:15 PM12/5/12
to mercu...@googlegroups.com, mercu...@googlegroups.com
Yes Getroproperty("alt") will give youtooltip. 

Regards,
Suman

sachin mahajan

unread,
Dec 7, 2012, 12:03:15 PM12/7/12
to mercu...@googlegroups.com
Hi all,

I tried with above code,following error occured

Cannot identify the object "[ Window ]" (of class Window). Verify that this object's properties match an object currently displayed in your application.

Line (34): "ToolTip = Window("nativeclass:=tooltips_class32").GetROProperty("text")". 


Could you please help on the same.

Kamran

unread,
Dec 7, 2012, 12:23:16 PM12/7/12
to mercu...@googlegroups.com
can you post all property picture of that object?

--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to Mercu...@googlegroups.com
To unsubscribe from this group, send email to
MercuryQTP+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en



--
Regards,
Muhammad Kamran

venkata bala subramanyam

unread,
Dec 9, 2012, 9:29:30 PM12/9/12
to mercu...@googlegroups.com
Hi why dont use this ..

browser("creationtime:=0").page("title:=.*").WebElement("text:=Yahoo!").FireEvent
"onmouseover"
Wait(1)
Msgbox browser("creationtime:=0").page("title:=.*").WebElement("text:=Yahoo!").Object.title

Note Make sure to use Entire object in Object reposptory
Venkata Bala

Akash Kashyap

unread,
May 29, 2014, 4:24:03 AM5/29/14
to mercu...@googlegroups.com
Hi All,

Try This.. 100% you will be able to solve your issues..

'Move mouse over <Search> button

Set DR = CreateObject("Mercury.DeviceReplay")
XX = Browser("Browser_3").Page("Page_3").SAPButton("Search").GetROProperty("abs_x")
YY = Browser("Browser_3").Page("Page_3").SAPButton("Search").GetROProperty("abs_y")
H = Browser("Browser_3").Page("Page_3").SAPButton("Search").GetROProperty("height")
W = Browser("Browser_3").Page("Page_3").SAPButton("Search").GetROProperty("width")

X1 = XX+W/2
Y1=YY+H/2

DR.MouseMove X1, Y1
wait 1
'Capture the tooltip
ToolTip = Window("nativeclass:=tooltips_class32").GetROProperty("text")
wait 1
Reply all
Reply to author
Forward
0 new messages