Counting rows in a table

Class library usage, coding and language questions.
nbeule
Posts: 1
Joined: Fri May 24, 2019 1:20 pm

Counting rows in a table

Post by nbeule » Fri May 24, 2019 1:31 pm

There are a million posts about this. I've read them all and still need help. To me this: repository.FrmMain.dgvIntervals.Rows.Count where dgvIntervals is a table makes all the sense in the world but I always get 0. I made a variable for my rows and indexed through them while counting, but it's very slow and I need to do this multiple times. I also tried:

IEnumerable<Ranorex.Row> rowList = repository.PART_GridViewVirtualizingPanel.Find<Ranorex.Row>(./Row)
Dim includedCount As Integer = rowList.Count

but I can't find much reference online to the things it uses so I dont understand why it breaks. Any help is welcome thanks!
Attachments
table.rxsnp
(966.08 KiB) Downloaded 6 times

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

Re: Counting rows in a table

Post by odklizec » Mon May 27, 2019 8:49 am

Hi,

The problem is, that the table in your snapshot does not act as standard table, with rows and columns ;) The 'rows' are actually stored in 'Container' element...
table_container_rows.png
table_container_rows.png (65.17 KiB) Viewed 163 times
The table appears to be WPF-based, so I would suggest to try different WPF plugin settings. This may help with correct table appearance. Otherwise, you must utilize different approach.

For example, this xpath returns all table 'rows', stored as containers (except 'header' container):

Code: Select all

/form[@automationid='BuilderWindow']//table[@automationid='sfDataGridIncluded']/container[@automationid='PART_VisualContainer']/container[@type!='DepoGroup<HeaderRowControl>']
Now you can use this code, which should return count of row-containers. The repoElement parameter should be filled with repository element, with above xpath:

Code: Select all

    public static void ContainersCount(RepoItemInfo repoElement)
    {
		IList<Ranorex.Container> containerList = repoElement.CreateAdapters<Ranorex.Container>();
		int containerCount = containerList.Count;
    }
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