Micro Focus QTP (UFT) Forums
Using static descriptive programming how to count no. of objects on any webpage - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Using static descriptive programming how to count no. of objects on any webpage (/Thread-Using-static-descriptive-programming-how-to-count-no-of-objects-on-any-webpage)



Using static descriptive programming how to count no. of objects on any webpage - alpha1 - 07-21-2015

Hi,
I wanted to count no. of objects on Google homepage using static programming, i mean without creating object first(the way we do in dynamic one).


Pls tell me what is wrong in below statement


Code:
Set P = Browser(creationtime=0).page(tile=Google).WebButton(type=submit, html tag=INPUT)

MsgBox P.Count()




Pls help

Thanks


RE: Using static descriptive programming how to count no. of objects on any webpage - abhideshpande001 - 07-22-2015

Try this. Might Help.

Code:
Set P = Browser(creationtime=0).page(tile=Google).Chieldobjects(WebButton(type=submit, html tag=INPUT))

MsgBox P.Count()



RE: Using static descriptive programming how to count no. of objects on any webpage - alpha1 - 07-22-2015

Hi,
Thanks, I tried this,

Code:
Set P = Browser("creationtime:=0").page("title:=Google").Childobjects(WebButton("type:=submit", "html tag:=INPUT"))

MsgBox P.Count()

It gives count as 62. And we obviously don't have 62 webbuttons on Google homepage, When I also added property value "name:=Google Search" still gave count as 62 when only one 'Google Search' button is thr on google homepage. Is above code giving total no. of all child objects on homepage. pls see attachment

So, how to retrieve count specifically for any object like webbutton, links etc using static programming.

Thanks for the help!


RE: Using static descriptive programming how to count no. of objects on any webpage - alpha1 - 07-24-2015

Hi Guys,
Pls help!


RE: Using static descriptive programming how to count no. of objects on any webpage - kotaramamohana - 08-11-2015

Hi,
Here is my approach, Dont know other logic.
Code:
Set p=browser("CreationTime:=0").page("micClass:=Page").ChildObjects(WebButton("micClass:=WebButton"))
i=0
For x=0 to p.count-1 step 1
If p(x).getroproperty("micClass") = "WebButton" Then
    i=i+1
End If
Next
msgbox "Count :" &i