Finding controls in Data Grid? using Coded UI RRS feed

  • Question

  • I am automating the WPF application using coded UI, I have a data grid in which first toggle button in first row of first cell. I am able to find the controls up to this first row, when we click on first toggle button, another row will display, actually it is not second row. It is a custom control within the custom control again one more data grid is exists with in that data grid first row of first column having the second toggle button. Problem here i am not able to find this custom control or second data grid.

    when i ask the developer about these control hierarchic, they said data grid with in the data grid. Please help me out. When i record i am getting the properties of second toggle button, but the controls is not locating.

    My code for the data grid: 

    // Table

     WpfTable tableGrid = new WpfTable(DashboardTabList.DashboardPIPrismPrismExtensioTabPage);
    tableGrid.SearchProperties.Add(WpfTable.PropertyNames.ClassName, "Uia.DataGrid");

    WpfRow rowGrid = new WpfRow(tableGrid);
     rowGrid.SearchProperties.Add(WpfRow.PropertyNames.ClassName, "Uia.DataGridRow"); rowGrid.WaitForControlExist();

    WpfCell celGrid = new WpfCell(rowGrid);
     celGrid.SearchProperties.Add(WpfCell.PropertyNames.ClassName, "Uia.DataGridCell");

    first toggle button , click event

    WpfToggleButton toglButtonShowall = new WpfToggleButton(celGrid);
     toglButtonShowall.SearchProperties.Add(WpfToggleButton.PropertyNames.AutomationId, "ShowDetails");

    from here i am unable to find the control for second toggle button

    WpfCustom custDetaPre = new WpfCustom(rowGrid);
     custDetaPre.SearchProperties.Add(WpfCustom.PropertyNames.ClassName, "Uia.DataGridDetailsPresenter");


    I am getting exception @custDetaPre [it is custom control] , control not find exception.

    Wednesday, May 24, 2017 8:43 AM