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:

Post a Comment