How to Capture ToolTips or Alt Property of an Image Through QTP


I was in a project where there was a peculiar requirement to capture tool tips through script. I got several request also to write a code which will capture the tool tips. I tried with Google!! I got a very nice thread of motevich. I found this is a great solution. This also solves the problem of capturing the alt property of the Image.Here is a solution for capturing Tooltips of image.Even in my project I have used this code only.





Dim descImage, listImages, attrAltText, attrSrcText

Browser("Main Page - Wikipedia,").Sync
Browser("Main Page - Wikipedia,").Page("Main Page - Wikipedia,").Sync

' Create description for all images on a Web page.
' For that we use "html tag" property and its value "IMG"
Set descImage = Description.Create
descImage("html tag").value = "IMG"

' Get all images which match the above description
Set listImages = Browser("Main Page - Wikipedia,").Page("Main Page - Wikipedia,").ChildObjects(descImage)

' Check tool tips of images
For i = 0 To listImages.Count - 1
attrAltText = listImages(i).GetROProperty("alt")
attrSrcText = listImages(i).GetROProperty("src")

If attrAltText <> "" Then
MsgBox "Image src: " & attrSrcText & vbNewLine & "Tool tip: " & attrAltText
End If
Next


----------------------------------------------------------
This code is taken from the below written blog.
http://motevich.blogspot.com/2008/06/qtp-tool-tips-for-images.html
Credit goes to the owner of this blog.you can refer this blog for further query.
How to Capture ToolTips or Alt Property of an Image Through QTP How to Capture ToolTips or Alt Property of an Image Through QTP Reviewed by Animesh Chatterjee on January 20, 2009 Rating: 5

No comments:

Powered by Blogger.