Identify rows and columns within WPF table

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
Posts: 67
Joined: Fri Nov 26, 2010 3:39 pm

Identify rows and columns within WPF table

Post by anja » Fri Nov 18, 2011 12:33 pm


I've got a problem with identifying the rows and columns within a WPF table.

Attached you find a Ranorex-Snapshot of the element (/form[@name='Select Comm DTM to add.']/element/table[@automationid='list']).
1.) Within this table, there is a header row named Row'-1'. Within this row, it is not possible to identify which columnheader belongs to which columnindex. I need this information for checking all elements in the devicetype row.

2.) The content of the table could be changed. I have to check if all expected elements are listed within this table. The rows are identified via following ranorex-path:
/form[@name='Select Comm DTM to add.']/element/table/row[2] --> first row in the table
In the objectrepository it is not possible to replace the '2' within the row with a variable. --> How can I address the rows?

Thank you very much...

Best regards
Snapshot of Table
(189.34 KiB) Downloaded 204 times

User avatar
Support Team
Site Admin
Site Admin
Posts: 11774
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Identify rows and columns within WPF table

Post by Support Team » Fri Nov 18, 2011 2:50 pm


Ad 1:
If you click on the cell you are looking for, open the Detail tab on the right side of the spy and there is an attribute ChildIndex. You could use this, it is 0 for the first column.
e.g. /form[@name='Select Comm DTM to add.']/element/table/row/cell[@childindex='0'] will give you all cells within first col.

Ad 2:
You can get the all the rows and cells within a Table with the following code:
IList<Row> rowList = repo.YourFolder.YourTable.FindDescendants<Row>();
      foreach(Row rowItem in rowList){
        Report.Info("Row index: "+rowItem.Index);
        IList<Cell> cellList = rowItem.Cells;
        foreach(Cell cellItem in cellList){
          Report.Info("Cell Info: "+cellItem.Text);
Or you can also use the following path to get all rows: /form[@name='Select Comm DTM to add.']/element/table[@automationid='list']/row.
I hope this answered your questions.

Ranorex Support Team