Count of all items in listview

Ask general questions here.
sanwery93
Posts: 1
Joined: Wed Sep 21, 2016 3:12 pm

Count of all items in listview

Post by sanwery93 » Wed Sep 21, 2016 3:22 pm

Hello guys, I'm having trouble getting the count of all items in my listview for my application.

Here is my code in c#:
int records = repo.BlazeRouteAdminTool.LsvEntities.Items.Count;
Ranorex.Report.Info("Number of records in Entities Grid: " + records);


In my listview I check that it has over 700 items, yet this code only shows me 14. Because it prints out only what it sees in the image, which is 14. But if I scroll down there are hundreds of more items. Is there a way to get a count of all items in my listview (700 items)?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Count of all items in listview

Post by odklizec » Sun Sep 25, 2016 2:43 pm

Hi,

This problem is most probably caused by so called "lazy-loading" where only the necessary items from list are loaded in memory. What kind of technology is the list in question? If WPF, you can try the suggestion from here:
http://www.ranorex.com/forum/how-to-ide ... tml#p31721

Otherwise, you will have to create a custom code, which will scroll the list (row-by-row/page-by-page), read the visible items from the list, save all new items to iList and repeat this process until all items are read. Then you can get the number of items from iList.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration