Saturday, May 31, 2008

To Count the no of objects in a Web Page

'Open a Google page and count the no of links and buttons in that page

If Browser("index:=0").Exist(1) then 'If Browser is already opened
a=Browser(index:=0").GetROProperty("hwnd")
Browser("hwnd:="&a).Navigate("http://www.google.com")
Browser("hwnd:="&a).Sync
wait(2)
Else 'If Browser is not opened
Systemutil.Run "IEXPLORE.exe"
a=Browser("index:=0").GetROProperty("hwnd")
Browser("hwnd:="&a).Navigate("http://www.google.com")
Browser("hwnd:="&a).Sync
wait(2)
End If

Set butObj=Description.Create ''''For Buttons
butObj("html tag").value="INPUT"
butObj("type").vlaue="submit"

Set linkObj=Description.Create ''''For Links
linkObj("html tag").value="A"

Set Buttons=browser("hwnd:=&a).page(title:=.*") .ChildObjects(butObj)
Set Links=browser("hwnd:=&a).page(title:=.*") .ChildObjects(linkObj)

msgbox "Total Button are: "&Buttons.count
msgbox " Total Links are: "&Links.count

No comments:

About Me

My photo
Hi all,I am Arun Singh Rajaputra. I am working as a Project Lead in a reputed organization in Hyderabad, AP, India. I have little bit knowledge on Quick Test Professional and like to share my knowledge to all through this blog.

Subscribe to get updates on this blog

Enter your email address:

NOTE

Some of the posts posted in this blog are collected and most of them have been prepared by me. If any one have objections regarding any copied posts. Please mail me so that I can take a necessary action on that post.