Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Three filters to get object count
#1
Solved: 11 Years, 4 Months, 1 Week ago
How do I use three filters to grab the count of web objects on a page?

I want to get the number of objects on a page where the objects have these values:

micClass = WebElement
html tag = SPAN
x = 180

Here is the code I have so far:

=================================================

Code:
'Gather the number of filtered objects on the website.

On Error Resume Next
webCount = 0
Set Doc = Browser("micClass:=Browser").Page("micClass:=Page").Object

'Loop through all the objects in the page.

For Each Element In Doc.all
If Element.TagName = "SPAN" and Element.x = 180 then
webCount = webCount + 1
End If
Next

Msgbox "The number of objects are " & webCount
=================================================

The msgbox should come back with a count of 4 instead it comes back as 93.

Any ideas?

SBsteven
Reply
#2
Solved: 11 Years, 4 Months, 1 Week ago
you should look in the page child objects not in the page.object also you have not serached for webElement object.
try the code below
Code:
Set Desc = Description.Create()
Desc("micclass").Value = "WebElement"
Desc("html tag").Value = "SPAN"
Desc("X").value = 180

Set Doc = Browser("micClass:=Browser").Page("micClass:=Page").ChildObjects(Desc)

MsgBox "Number of Edits: " & Doc.Count

Sorry for the typo, Please read Number of webelements in the last statement.

Reply
#3
Solved: 11 Years, 4 Months, 1 Week ago
Saket,

Thanks much for helping me out with this. I feel that I am much closer now. But when running your code I am getting a "General Run Error" on this line:

Code:
Set Doc = Browser("micClass:=Browser").Page("micClass:=Page").ChildObjects(Desc)
And I am unsure why. Do you or anyone here have any ideas?

Thanks!!
SBsteven
Reply
#4
Solved: 11 Years, 4 Months, 1 Week ago
I finally have the answer. After posting on a few message forums and some Google searching, here is the code that works..YAY!

==========================================================
Code:
Dim oDesc        'Description Object
Dim colObject    'Object Collection

    Set oDesc = Description.Create
    oDesc("micclass").Value = "WebElement"
    oDesc("html tag").Value = "SPAN"
    oDesc("x").Value = 180

Set colObject = Browser("micClass:=Browser").Page("micClass:=Page").ChildObjects( oDesc )

'Retrieve the count
iCount = colObject.Count

msgbox iCount
=========================================================

SBsteven
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Count the number of times the object appeared in the run yonobev 8 5,421 10-08-2009, 02:58 PM
Last Post: Saket
  Diff. between page checkpoint link count and childobj count anemuday 0 2,253 07-20-2008, 10:11 PM
Last Post: anemuday

Forum Jump:


Users browsing this thread: 2 Guest(s)