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:

Post a Comment