For example, how to get tool tip ('Go to My Yahoo!') from the yahoo page:
This QTP tutorial shows and explains How to get tool tip in QuickTest Professional.
Actually, this is not a difficult task. The steps are:
- Place mouse cursor over the link
- Wait for tool tip
- Get text of shown tool tip
This QTP script captures a text of a tool tip:
' Place mouse cursor over the link
Browser("Yahoo!").Page("Yahoo!").WebElement("text:=My Yahoo!").FireEvent "onmouseover"
wait 1
' Grab tooltip
ToolTip = Window("nativeclass:=tooltips_class32").GetROProperty("text")
Browser("Yahoo!").Page("Yahoo!").WebElement("text:=My Yahoo!").FireEvent "onmouseover"
wait 1
' Grab tooltip
ToolTip = Window("nativeclass:=tooltips_class32").GetROProperty("text")
Please, pay attention on details:
- We use FireEvent("onmouseover") to simulate mouse placing over the link
- Function wait(1) waits 1 second for a tool tip
- To get tool tip text, we use:
Window("nativeclass:=tooltips_class32").GetROProperty("text")
Let's run our code and compare captured tool tip with expected ('Go to My Yahoo!'):
As you can see, above QTP script captures correct text of a Tool tip.
I hope, you will add this script to your QTP functions library.
Related articles:
- How to record QTP script - VIDEO tutorial
- QTP - How to set/get system time and date
- QTP VIDEO - How to run QTP test from command line
- QTP VIDEO - How to capture dynamic text
- QTP - How to get font size/color, background color and other attributes of controls
- How to minimize/maximize QTP window before the QTP script execution
- How to execute QTP script from LoadRunner
- All QTP visual tutorials
Dear readers,
Do you have comments or questions on this topic? If yes, please post them.
It's very important to know your opinions...
They allow to create more useful, interesting, and informative blog. This is my primary goal.
--
Dmitry
9 comments:
This script is not working for me, it shows the following error
message :
Cannot identify the object "[ Window ]" (of class Window). Verify that this object's properties match an object currently displayed in your application.
and in details tab:
Line (7): "ToolTip = Window("nativeclass:=tooltips_class32").GetROProperty("text")"
@Shaik's,
It seems that tool tip is not shown.
Do you wait for its appearance?
Are you sure that it did disappear?
Hello,
i am testing a web application,
and it has alternate text when you mouse over a link.
the example you have provided is for tool tip.
can you answer how to capture the alternatetext?
and what exactly the line
("nativeclass:=tooltips_class32").GetROProperty("text")" does?
thanks
@kishore,
What is "alterante text"?
As I understand, this is a tool tip.
Did you try the solution shown in the present article? Did it work?
yes i tried the same code but didn't work.
can you explain the native class code?
i got the below error
Cannot identify the object "[ Window ]" (of class Window).
after using the getRO property, should i use if statement to get the text?
alternate text is, when you mouse over on any link, the text that is displayed underneath the link.
tool tip might also be the same, not sure but the tool tip code didn't work for the alternate text
hello, the script worked for me, but everytime mouseover comes, i have to manually move the mouse on to the link...is there any way that we can automate mouse over thing on to the link?
Hello Dmitry,
i have a question regarding mousehovering on links and how to test whether the link is underlined when mouse hovered on that link?
please reply
Hi I have tried that.But Iam getting error that not able to identify the window class!
Post a Comment