Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Count number of specific elements on a web page
#1
Solved: 10 Years, 8 Months, 3 Weeks ago
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
Solved: 10 Years, 8 Months, 3 Weeks ago
Hi

Use 'ChildItemCount' function.

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

Hope this will help you.

~Regards
Reply
#3
Solved: 10 Years, 8 Months, 3 Weeks ago
Thx, I will give it a try
Reply
#4
Solved: 10 Years, 8 Months, 3 Weeks ago
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
Solved: 10 Years, 8 Months, 3 Weeks ago
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
Solved: 10 Years, 8 Months, 3 Weeks ago
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
Solved: 10 Years, 8 Months, 3 Weeks ago
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
Solved: 10 Years, 8 Months, 3 Weeks ago
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 4,258 10-01-2019, 10:44 AM
Last Post: shilpi952
Question Find specific records in a SwfTreeView on different node levels lotos 0 2,198 10-06-2017, 05:14 AM
Last Post: lotos
  Click on calender on specific date. venkatesh9032 1 3,725 12-02-2015, 07:30 PM
Last Post: nistalaramesh
  DP Web Browser/Page issues rstimers 1 2,294 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 2,600 11-13-2013, 10:24 PM
Last Post: sai rajesh

Forum Jump:


Users browsing this thread: 2 Guest(s)