Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Count number of specific elements on a web page
#1
Hi all

I have 2 web pages in my app that are almost identical. I cannot identify them by URL or objects as the objects are named runtime.

Page 1 has 3 web radio groups and page 2 has 6 web radio groups. My idea now is to count the number of elements i.e. web radio groups, but how do i do that with descriptive programming ?
Reply
#2
Hi

Use 'ChildItemCount' function.

Code:
ItemIndex=Obj.ChildItemCount(row, col, "WebRadioGroup")

Hope this will help you.

~Regards
Reply
#3
Thx, I will give it a try
Reply
#4
hi,

As per the above discussion, count function will give you the count of your desired elements.

Now before that,to differntiate the browers you can use ordinal identifiar (EX: Index).

Code:
Browser("Name:= abc","Index :=0").Page("innerhtml := def").Activate Browser("Name:= abc","Index :=1").Page("innerhtml := def").Activate


Use the appropriate names.Hope it should work for you...
Smile
Reply
#5
Hi QTPLearn,

Do you really think that using "ChildItemCount" method would solve the Janris Question?

FYI, "ChildItemCount" method is applicable for Object classes such as WebTable,SAPTable,WbfGrid only.
Reply
#6
Hi Sreekant

I have used 'Child ItemCount' for my project for counting checkboxes,radiobuttons,webelements,thats why I suggested that but if you have any better solution then please provide it.

It will help all of us to learn new approach.

~Regards
Reply
#7
HI,
I would suggest to try in the below approach.

Code:
Set Brw=Description.Create Brw("micclass").Value="Browser" Set Pg=Description.Create Pg("micclass").Value="Page" Set Wrg=Description.Create Wrg("micclass").Value="WebRadioGroup" Set Brw_Collection=Desktop.ChildObjects(Brw) msgbox "No. of Browsers: "& Brw_Collection.count Set Br1_Pgcollection=Brw_Collection(0).childObjects(Pg) Set Br1_Pg1_WrgCollection=Br1_Pgcollection(0).ChildObjects(Wrg) msgbox "No. of WebRadioGroups in Browser1,Page1 : "&Br1_Pg1_WrgCollection.count Set Br2_Pgcollection=Brw_Collection(1).childObjects(Pg) Set Br2_Pg2_WrgCollection=Br2_Pgcollection(0).ChildObjects(Wrg) msgbox "No. of WebRadioGroups in Browser2,Page2 : "&Br2_Pg2_WrgCollection.count
Reply
#8
Hi Sreekanth,

Good solution.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Can QTP handle slick grid table in a web page qtplearner88 2 5,242 10-01-2019, 10:44 AM
Last Post: shilpi952
Question Find specific records in a SwfTreeView on different node levels lotos 0 2,839 10-06-2017, 05:14 AM
Last Post: lotos
  Click on calender on specific date. venkatesh9032 1 4,466 12-02-2015, 07:30 PM
Last Post: nistalaramesh
  DP Web Browser/Page issues rstimers 1 2,935 08-14-2015, 12:37 PM
Last Post: venkatesh9032
  How to get center data value in a odd number of rows and columns web table ... sai rajesh 0 3,236 11-13-2013, 10:24 PM
Last Post: sai rajesh

Forum Jump:


Users browsing this thread: 1 Guest(s)