Monday, June 1, 2009

Different ways to capture a tool tip in QTP.

Image Tool Tip

'Works fine for an image on http://www.google.co.in/, make sure that www.google.co.in is open in IE and then run the below two lines in QTP.

b=Browser("name:=Google").Page("title:=Google").WebElement("outertext:=India", "height:=110").Object.title
msgbox b






Link Tool Tip

'You have to place mouse manually over the link after clicking on Run in QTP as shown in the below screenshot - works on http://www.yahoo.com/

Browser("name:=Yahoo!").Page("title:=Yahoo!").Link("name:=My Yahoo!").mouseover
wait(1)
ttip =Window("nativeclass:=tooltips_class32").GetROProperty("text")
Msgbox ttip




Link Tool Tip

'Works fine on http://in.yahoo.com/?p=us for link named All Yahoo! Services.

ttip=Browser("name:=Yahoo! India").Page("title:=Yahoo! India").Link("name:=All Yahoo! Services").Object.title
msgbox ttip





Image Tool Tip

'Works fine on http://www.google.com/ for image, make sure google.com is open and run the below two lines in QTP
ttip=Browser("name:=Google").Page("title:=Google").Image("src:=http://www.google.com/intl/en_ALL/images/logo.gif").getROProperty("alt")
msgbox ttip





Search Box Tool Tip

'Works fine on http://www.google.com/ for search text box, make sure that google is open in IE and run the below two lines in QTP.

ttip=Browser("name:=Google").Page("title:=Google").WebEdit("name:=q").Object.title
msgbox ttip





WordPad Toolbar Icon Tool Tip

'Works fine on Wordpad, you DO NOT need to place the mouse manually. It tells you the tooltip of the New icon on toolbar below the File menu. Make sure that a WordPad is open and run the below lines in QTP.

Window("text:=Document - WordPad").WinToolbar("text:=Standard").MouseMove 5, 20
wait(1)
ttip =Window("nativeclass:=tooltips_class32").GetROProperty("text")
Msgbox ttip