Rasim Avci
Rasim Avci

Reputation: 63

Can not iterate in a WinTable

I have recorder a WinTable I want to check some rows value with my test value. Since new rows added everyday, row index value is dynamic and I need fo find it. I need to iterate all rows in order to get correct row I want to check values for. However I can not iterate for all rows in the table yet.

        #region Variable Declarations
        WinTable uIG1Table = this.UIProMANAGEWindow.UIMouldOperationWindow.UIG1Window.UIG1Table;
        #endregion
        Assert.AreEqual(this.OperationListTableControl1ExpectedValues.UIG1TableControlType, uIG1Table.ControlType.ToString());

When I have the row index I can correct row using GetRow

        WinRow dataGridrow = uIG1Table.GetRow(1);
        MessageBox.Show(dataGridrow.RowIndex.ToString());

When I do not have row index I need to iterate however I can not loop for all rows, code never goes in foreach loop.

        UITestControlCollection rows = uIG1Table.Rows;

        foreach (WinRow row in uIG1Table.Rows)

        {

            MessageBox.Show(row.RowIndex.ToString());
            foreach (WinCell cell in row.Cells)

            {
                MessageBox.Show(cell.Value);
            }

I also tried to apoproach rows as an array but didnt work

       // MessageBox.Show(rows[5].RowIndex.ToString());

Upvotes: 0

Views: 45

Answers (1)

Ankita Bansal
Ankita Bansal

Reputation: 46

It will not go in the for loop if there are zero rows in the "rows" collection. So you should check the row count for the collection.

You can definitely iterate over the WinTable by taking its children. UitestcontrolCollection rows = WinTable.GetChildren() and then putting this in for loop.

But, if there is another control in between Table and rows, then you need to check the hierarchy.

Upvotes: 1

Related Questions