Page 1 of 1

Identify rows and columns within WPF table

Posted: Fri Nov 18, 2011 12:33 pm
by anja
Hi,

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
Anja

Re: Identify rows and columns within WPF table

Posted: Fri Nov 18, 2011 2:50 pm
by Support Team
Hi,

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.

Regards,
Markus
Ranorex Support Team