Wednesday, December 3, 2008

To count the no of links and button 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 Button
Butobj("html tag").value = "INPUT"'For Button
Butobj("type").value="submit"'For Button

Set Linkobj=Description.Create()'For Link
Linkobj("html tag").value="A"'For Link

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.