Hi,
If you want to find the number of links, webedits, images etc controls on the page, then use following.
Function GetAllSpecificControls(Page, MicClass)
Set Desc = Description.Create()
Desc("micclass").Value = MicClass
Set GetAllSpecificControls = Page.ChildObjects(Desc)
End Function
Function GetAllEdits(Page)
Set GetAllEdits = GetAllSpecificControls(Page, "WebEdit")
End Function
Function GetAllButtons(Page)
Set GetAllButtons = GetAllSpecificControls(Page, "WebButton")
End Function
Function GetAllLinks(Page)
Set GetAllLinks = GetAllSpecificControls(Page, "Link")
End Function
Function GetAllImages(Page)
Set GetAllImages = GetAllSpecificControls(Page, "Image")
End Function
Set oPage = Browser("Google Sets").Page("Google Sets")
MsgBox "Number of Edits: " & GetAllEdits(oPage).Count
MsgBox "Number of Buttons: " & GetAllButtons(oPage).Count
MsgBox "Number of Links: " & GetAllLinks(oPage).Count
MsgBox "Number of Images: " & GetAllImages(oPage).Count
If you want to find the number of links, webedits, images etc controls on the page, then use following.
Function GetAllSpecificControls(Page, MicClass)
Set Desc = Description.Create()
Desc("micclass").Value = MicClass
Set GetAllSpecificControls = Page.ChildObjects(Desc)
End Function
Function GetAllEdits(Page)
Set GetAllEdits = GetAllSpecificControls(Page, "WebEdit")
End Function
Function GetAllButtons(Page)
Set GetAllButtons = GetAllSpecificControls(Page, "WebButton")
End Function
Function GetAllLinks(Page)
Set GetAllLinks = GetAllSpecificControls(Page, "Link")
End Function
Function GetAllImages(Page)
Set GetAllImages = GetAllSpecificControls(Page, "Image")
End Function
Set oPage = Browser("Google Sets").Page("Google Sets")
MsgBox "Number of Edits: " & GetAllEdits(oPage).Count
MsgBox "Number of Buttons: " & GetAllButtons(oPage).Count
MsgBox "Number of Links: " & GetAllLinks(oPage).Count
MsgBox "Number of Images: " & GetAllImages(oPage).Count
thanx trupti your code was correct and good.
ReplyDeletecan you share if want to make the code more dynamic IE not specifically for one web page
Replace
ReplyDeleteSet oPage = Browser("Google Sets").Page("Google Sets")
With
Set oPage = Browser("title:=[browser title]").Page("title:=[page title]")
hi trupti your code is rocking
ReplyDelete